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 granularity(self, granularity):
      if not isinstance(granularity, (int, float)):
          try:
              granularity = granularity_str_to_seconds(granularity)
          except:
              granularity = getattr(granularity, "freqstr", granularity)
      self._granularity = granularity
  
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 5 for calling the TemporalResample obj's underlying member method code with example usage: obj.granularity(granularity) without return types