class_docstr: Defines a policy to temporally resample a time series at a specified  granularity. Note that while this transform
  does support inversion, the recovered time series may differ from the input due to information loss when resampling.
class_docstr_tok: ["Defines","a","policy","to","temporally","resample","a","time","series","at","a","specified","granularity",".","Note","that","while","this","transform","does","support","inversion",",","the","recovered","time","series","may","differ","from","the","input","due","to","information","loss","when","resampling","."]
code: def train(self, time_series: TimeSeries):
      if self.trainable_granularity:
          granularity = infer_granularity(time_series.np_time_stamps)
          logger.warning(f"Inferred granularity {granularity}")
          self.granularity = granularity
  
      if self.trainable_granularity or self.origin is None:
          t0, tf = time_series.t0, time_series.tf
          if isinstance(self.granularity, (int, float)):
              offset = (tf - t0) % self.granularity
          else:
              offset = 0
          self.origin = t0 + offset
  
imports: from collections import OrderedDict
  import logging
  from typing import Union
  import numpy
  from merlion.transform.base import TransformBase, InvertibleTransformBase
  from merlion.utils import UnivariateTimeSeries, TimeSeries
  from merlion.utils.resample import infer_granularity, granularity_str_to_seconds, AlignPolicy, AggregationPolicy, MissingValuePolicy
label_desc: Use image node_id 10 for calling the TemporalResample obj's underlying member method code with example usage: obj.train(time_series) without return types