def state(self):
    """Returns a tuple containing this layer's state; may be empty.

    If the layer has sublayers, the state by convention will be
    a tuple of length `len(sublayers)` containing sublayer states.
    Note that in this case self._state only marks which ones are shared.
    """
    if not self.sublayers:
      return self._state
    else:
      return tuple(layer.state if s is None else s
                   for (layer, s) in zip(self.sublayers, self._state))
Returns a tuple containing this layer's state; may be empty.

    If the layer has sublayers, the state by convention will be
    a tuple of length `len(sublayers)` containing sublayer states.
    Note that in this case self._state only marks which ones are shared.
    
trax/layers/base.py