def weights(self):
    """Returns this layer's weights.

    Depending on the layer, the weights can be in the form of:

      - an empty tuple
      - a tensor (ndarray)
      - a nested structure of tuples and tensors

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

    Depending on the layer, the weights can be in the form of:

      - an empty tuple
      - a tensor (ndarray)
      - a nested structure of tuples and tensors

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