def init_from_file(self, file_name, weights_only=False, input_signature=None):
    """Initializes this layer and its sublayers from a pickled checkpoint.

    In the common case (`weights_only=False`), the file must be a gziped pickled
    dictionary containing items with keys `'flat_weights', `'flat_state'` and
    `'input_signature'`, which are used to initialize this layer.
    If `input_signature` is specified, it's used instead of the one in the file.
    If `weights_only` is `True`, the dictionary does not need to have the
    `'flat_state'` item and the state it not restored either.

    Args:
      file_name: Name/path of the pickled weights/state file.
      weights_only: If `True`, initialize only the layer's weights. Else
          initialize both weights and state.
      input_signature: Input signature to be used instead of the one from file.

    Returns:
      A `(weights, state)` tuple.
    """
    with tf.io.gfile.GFile(file_name, 'rb') as f:
      with gzip.GzipFile(fileobj=f, compresslevel=2) as gzipf:
        dictionary = pickle.load(gzipf)
    # In the current checkpoint format, we store weights in a separate
    # non-pickled file with the same name but added ".npy".
    if isinstance(dictionary['flat_weights'], int):
      if file_name.endswith('.pkl.gz'):
        weights_path = file_name[:-6] + 'weights.npy.gz'
      else:
        weights_path = file_name + '.npy'
      if not tf.io.gfile.exists(weights_path):  # old format compatibility
        weights_path = file_name + '.npy'
      dictionary['flat_weights'] = np_from_file(
          weights_path, compresslevel=dictionary['flat_weights'])
    if input_signature is None:
      input_signature = dictionary['input_signature']
    if weights_only and input_signature is not None:
      self.init(input_signature)
    weights_and_state_sig = self.weights_and_state_signature(input_signature)
    weights, state = unflatten_weights_and_state(
        dictionary['flat_weights'], dictionary['flat_state'],
        weights_and_state_sig, weights_only=weights_only)
    if not weights_only:
      self.state = state
    self.weights = weights
    return (self.weights, self.state)
Initializes this layer and its sublayers from a pickled checkpoint.

    In the common case (`weights_only=False`), the file must be a gziped pickled
    dictionary containing items with keys `'flat_weights', `'flat_state'` and
    `'input_signature'`, which are used to initialize this layer.
    If `input_signature` is specified, it's used instead of the one in the file.
    If `weights_only` is `True`, the dictionary does not need to have the
    `'flat_state'` item and the state it not restored either.

    Args:
      file_name: Name/path of the pickled weights/state file.
      weights_only: If `True`, initialize only the layer's weights. Else
          initialize both weights and state.
      input_signature: Input signature to be used instead of the one from file.

    Returns:
      A `(weights, state)` tuple.
    
trax/layers/base.py