code: def assert_equal_timedeltas(
      time_series: UnivariateTimeSeries, granularity, offset=None
  ):
      """
      Checks that all time deltas in the time series are equal, either to each
      other, or a pre-specified timedelta (in seconds).
      """
      if len(time_series) <= 2:
          return
      index = time_series.index
      offset = pd.to_timedelta(0) if offset is None else offset
      expected = (
          pd.date_range(start=index[0], end=index[-1], freq=granularity)
          + offset
      )
      deviation = expected - time_series.index[-len(expected) :]
      max_deviation = np.abs(deviation.total_seconds().values).max()
      assert (
          max_deviation < 2e-3
      ), f"Data must have the same time difference between each element of the time series"
  
imports: from bisect import bisect_left, bisect_right
  import itertools
  import logging
  from typing import Any, Callable, Dict, Iterable, Mapping, Sequence, Tuple, Union
  import warnings
  import numpy
  import pandas
  from merlion.utils.misc import ValIterOrderedDict
  from merlion.utils.resample import AggregationPolicy, AlignPolicy, MissingValuePolicy, get_date_offset, infer_granularity, reindex_df, to_pd_datetime, to_timestamp, to_offset
label_desc: Use image node_id 1 for calling a global function with example usage: assert_equal_timedeltas(time_series, granularity, offset) without return types