docs: def _get_time_bins(index, freq, closed, label, base):
      """Obtain the bins and their respective labels for resampling operations.
  
      Parameters
      ----------
      index : CFTimeIndex
          Index object to be resampled (e.g., CFTimeIndex named 'time').
      freq : xarray.coding.cftime_offsets.BaseCFTimeOffset
          The offset object representing target conversion a.k.a. resampling
          frequency (e.g., 'MS', '2D', 'H', or '3T' with
          coding.cftime_offsets.to_offset() applied to it).
      closed : 'left' or 'right', optional
          Which side of bin interval is closed.
          The default is 'left' for all frequency offsets except for 'M' and 'A',
          which have a default of 'right'.
      label : 'left' or 'right', optional
          Which bin edge label to label bucket with.
          The default is 'left' for all frequency offsets except for 'M' and 'A',
          which have a default of 'right'.
      base : int, optional
          For frequencies that evenly subdivide 1 day, the "origin" of the
          aggregated intervals. For example, for '5min' frequency, base could
          range from 0 through 4. Defaults to 0.
  
      Returns
      -------
      datetime_bins : CFTimeIndex
          Defines the edge of resampling bins by which original index values will
          be grouped into.
      labels : CFTimeIndex
          Define what the user actually sees the bins labeled as.
      """
  
      if not isinstance(index, CFTimeIndex):
          raise TypeError('index must be a CFTimeIndex, but got '
                          'an instance of %r' % type(index).__name__)
      if len(index) == 0:
          datetime_bins = labels = CFTimeIndex(data=[], name=index.name)
          return datetime_bins, labels
  
      first, last = _get_range_edges(index.min(), index.max(), freq,
                                     closed=closed,
                                     base=base)
      datetime_bins = labels = cftime_range(freq=freq,
                                            start=first,
                                            end=last,
                                            name=index.name)
  
      datetime_bins, labels = _adjust_bin_edges(datetime_bins, freq, closed,
                                                index, labels)
  
      if label == 'right':
          labels = labels[1:]
      else:
          labels = labels[:-1]
  
      # TODO: when CFTimeIndex supports missing values, if the reference index
      # contains missing values, insert the appropriate NaN value at the
      # beginning of the datetime_bins and labels indexes.
  
      return datetime_bins, labels