class_docstr: Variant of vanilla numerical encoder, supports dynamic mean re-scaling
docstr: :param data: A pandas series containing the numbers to be encoded
  :param dependency_data: dict with grouped_by column info, to retrieve the correct normalizer for each datum
  
  :returns: A torch tensor with the representations of each number
docstr_tok: [":","param","data",":","A","pandas","series","containing","the","numbers","to","be","encoded",":","param","dependency_data",":","dict","with","grouped_by","column","info",",","to","retrieve","the","correct","normalizer","for","each","datum",":","returns",":","A","torch","tensor","with","the","representations","of","each","number"]
code: def encode(
      self,
      data: Union[np.ndarray, pd.Series],
      dependency_data: Dict[str, List[pd.Series]] = {},
  ):
      """
      :param data: A pandas series containing the numbers to be encoded
      :param dependency_data: dict with grouped_by column info, to retrieve the correct normalizer for each datum
  
      :returns: A torch tensor with the representations of each number
      """  # noqa
      if not self.is_prepared:
          raise Exception(
              'You need to call "prepare" before calling "encode" or "decode".'
          )
  
      if not dependency_data:
          dependency_data = {"__default": [None] * len(data)}
  
      if isinstance(data, pd.Series):
          data = data.values
  
      # get array of series-wise observed means
      if self.normalizers is None:
          means = np.full((len(data)), fill_value=self._abs_mean)
      else:
          # use global mean as default for novel series
          means = np.full(
              (len(data)),
              fill_value=self.normalizers["__default"].abs_mean,
          )
  
          def _get_group_mean(group) -> float:
              if (group,) in self.normalizers:
                  return self.normalizers[(group,)].abs_mean
              else:
                  return self.normalizers["__default"].abs_mean
  
          for i, group in enumerate(
              list(zip(*dependency_data.values()))
          ):  # TODO: support multigroup
              if group[0] is not None:
                  means = np.vectorize(_get_group_mean, otypes=[float])(
                      group[0].values
                  )
  
      if len(data.shape) > 1 and data.shape[1] > 1:
          if len(means.shape) == 1:
              means = np.expand_dims(means, 1)
          means = np.repeat(means, data.shape[1], axis=1)
  
      def _norm_fn(x: float, mean: float) -> float:
          return x / mean
  
      # nones = np.vectorize(self._none_fn, otypes=[float])(data)  # TODO
      encoded = np.vectorize(_norm_fn, otypes=[float])(data, means)
      # encoded[nones] = 0  # if measurement is None, it is zeroed out  # TODO
  
      # TODO: mask for where mean is 0, then pass real as-is
  
      return torch.Tensor(encoded).unsqueeze(1)
  
file_path: lightwood/lightwood/encoder/numeric/ts_numeric.py
imports: from typing import Union, List, Dict
  import torch
  import numpy
  import pandas
  from lightwood.encoder.numeric import NumericEncoder
label_desc: Use image node_id 2 for calling the TsNumericEncoder obj's underlying member method code with example usage: obj.encode(data, dependency_data) and returns: torch, unknown, self, self