code: def get_cutoff(
      obj,
      cutoff=0,
      return_index=False,
      reverse_order=False,
      check_input=False,
      convert_input=True,
  ):
      """Get cutoff = latest time point of time series or time series panel.
  
      Assumptions on obj are not checked, these should be validated separately.
      Function may return unexpected results without prior validation.
  
      Parameters
      ----------
      obj : sktime compatible time series data container or pandas.Index
          if sktime time series, must be of Series, Panel, or Hierarchical scitype
          all mtypes are supported via conversion to internally supported types
          to avoid conversions, pass data in one of GET_CUTOFF_SUPPORTED_MTYPES
          if pandas.Index, it is assumed that last level is time-like or integer,
          e.g., as in the pd.DataFrame, pd-multiindex, or pd_multiindex_hier mtypes
      cutoff : int, optional, default=0
          current cutoff, used to offset index if obj is np.ndarray
      return_index : bool, optional, default=False
          whether a pd.Index object should be returned (True)
              or a pandas compatible index element (False)
          note: return_index=True may set freq attribute of time types to None
              return_index=False will typically preserve freq attribute
      reverse_order : bool, optional, default=False
          if False, returns largest time index. If True, returns smallest time index
      check_input : bool, optional, default=False
          whether to check input for validity, i.e., is it one of the scitypes
      convert_input : bool, optional, default=True
          whether to convert the input (True), or skip conversion (False)
          if skipped, function assumes that inputs are one of GET_CUTOFF_SUPPORTED_MTYPES
  
      Returns
      -------
      cutoff_index : pandas compatible index element (if return_index=False)
          pd.Index of length 1 (if return_index=True)
  
      Raises
      ------
      ValueError, TypeError, if check_input or convert_input are True
          exceptions from check or conversion failure, in check_is_scitype, convert_to
      """
      from sktime.datatypes import check_is_scitype, convert_to
  
      # deal with VectorizedDF
      if hasattr(obj, "X"):
          obj = obj.X
  
      if isinstance(obj, pd.Index):
          return _get_cutoff_from_index(
              idx=obj,
              return_index=return_index,
              reverse_order=reverse_order,
          )
  
      if check_input:
          valid = check_is_scitype(
              obj, scitype=["Series", "Panel", "Hierarchical"]
          )
          if not valid:
              raise ValueError(
                  "obj must be of Series, Panel, or Hierarchical scitype"
              )
  
      if convert_input:
          obj = convert_to(obj, GET_CUTOFF_SUPPORTED_MTYPES)
  
      if cutoff is None:
          cutoff = 0
      elif isinstance(cutoff, pd.Index):
          if not len(cutoff) == 1:
              raise ValueError(
                  "if cutoff is a pd.Index, its length must be 1, but"
                  f" found a pd.Index with length {len(cutoff)}"
              )
          if len(obj) == 0 and return_index:
              return cutoff
          cutoff = cutoff[0]
  
      if len(obj) == 0:
          return cutoff
  
      # numpy3D (Panel) or np.npdarray (Series)
      if isinstance(obj, np.ndarray):
          if obj.ndim == 3:
              cutoff_ind = obj.shape[-1] + cutoff - 1
          if obj.ndim < 3 and obj.ndim > 0:
              cutoff_ind = obj.shape[0] + cutoff - 1
          if reverse_order:
              cutoff_ind = cutoff
          if return_index:
              return pd.RangeIndex(cutoff_ind, cutoff_ind + 1)
          else:
              return cutoff_ind
  
      # define "first" or "last" index depending on which is desired
      if reverse_order:
          ix = 0
          agg = min
          agg_str = "min"
      else:
          ix = -1
          agg = max
          agg_str = "max"
  
      def sub_idx(idx, ix, return_index=True):
          """Like sub-setting pd.index, but preserves freq attribute."""
          if not return_index:
              return idx[ix]
          res = idx[[ix]]
          if hasattr(idx, "freq"):
              if idx.freq is None:
                  res.freq = pd.infer_freq(idx)
              else:
                  if res.freq != idx.freq:
                      res.freq = idx.freq
          return res
  
      if isinstance(obj, pd.Series):
          return sub_idx(obj.index, ix, return_index)
  
      # nested_univ (Panel) or pd.DataFrame(Series)
      if isinstance(obj, pd.DataFrame) and not isinstance(
          obj.index, pd.MultiIndex
      ):
          objcols = [
              x for x in obj.columns if obj.dtypes[x] == "object"
          ]
          # pd.DataFrame
          if len(objcols) == 0:
              return (
                  sub_idx(obj.index, ix)
                  if return_index
                  else obj.index[ix]
              )
          # nested_univ
          else:
              idxx = [
                  sub_idx(x.index, ix, return_index)
                  for col in objcols
                  for x in obj[col]
              ]
              return agg(idxx)
  
      # pd-multiindex (Panel) and pd_multiindex_hier (Hierarchical)
      if isinstance(obj, pd.DataFrame) and isinstance(
          obj.index, pd.MultiIndex
      ):
          from pandas.core.indexes.base import ensure_index
  
          inst_levels = list(range(obj.index.nlevels - 1))
          cutoff = (
              obj.index.to_frame()
              .groupby(level=inst_levels, sort=False)
              .nth(ix)
              .iloc[:, -1]
              .agg(agg_str)
          )
          if return_index:
              cuttoff_idx = ensure_index([cutoff])
              time_idx = obj.index.levels[-1]
              if (
                  hasattr(time_idx, "freq")
                  and time_idx.freq is not None
              ):
                  if cuttoff_idx.freq != time_idx.freq:
                      cuttoff_idx.freq = time_idx.freq
              return cuttoff_idx
          else:
              return cutoff
  
      # df-list (Panel)
      if isinstance(obj, list):
          idxs = [sub_idx(x.index, ix, return_index) for x in obj]
          return agg(idxs)
  
file_path: sktime/sktime/datatypes/_utilities.py
imports: import numpy
  import pandas
label_desc: Use image node_id 5 for calling a global function with example usage: get_cutoff(obj, cutoff, return_index, reverse_order, check_input, convert_input) and returns: _get_cutoff_from_index, cutoff, res, sub_idx, agg, pd, cutoff_ind, idx, unknown, agg, cuttoff_idx, cutoff, cutoff