code: def _shift(x, by=1, return_index=False):
      """Shift time point `x` by a step (`by`) given frequency of `x`.
  
      Parameters
      ----------
      x : pd.Index, pd.Period, int. If pd.Index or pd.Period, must have `freq` attribute.
          If pd.Index, must be of integer type, PeriodIndex, or DateTimeIndex
          Time point to shift
      by : int, optional, default=1
      return_index : bool, optional, default=False
          whether to return an index element (False) or a pandas Index (True)
  
      Returns
      -------
      ret : pd.Index if return_index = True; int, pd.Period, or pd.Timestamp if False.
          Shifted time point, `x` shifted by `by` periods
          if return_index = True: pd.Index coerced `x`, shifted by `by` periods.
          if return_index = False: index element coerced `x`, shifted by `by` periods.
              if `x` is index, is coerced to index element by selecting first element
          Period shift is integer for `x: int`, and `freq` if `x` is temporal with `freq`
      """
      if isinstance(x, pd.Timestamp):
          raise TypeError(
              "_shift does not support x of type pd.Timestamp"
          )
  
      # we ensure idx is pd.Index, x is first (and usually only) element
      if isinstance(x, pd.Index):
          idx = x
          x = idx[0]
      else:
          idx = pd.Index([x])
  
      # if we want index, we can simply use add dunder or shift
      if return_index:
          if pd.api.types.is_integer_dtype(idx):
              return idx + by
          else:
              return idx.shift(by)
  
      # if not return_index, i.e., we want an index element
      assert isinstance(
          x, (pd.Period, pd.Timestamp, int, np.integer)
      ), type(x)
      assert isinstance(by, (int, np.integer)) or is_integer_index(
          by
      ), type(by)
  
      # we need to get freq from idx, since pd.Timestamp freq is deprecated
      if isinstance(x, pd.Timestamp):
          by *= idx.freq
      return x + by
  
file_path: sktime/sktime/utils/datetime.py
imports: import warnings
  from functools import singledispatch
  from typing import Optional, Tuple, Union
  import numpy
  import pandas
  from sktime.datatypes import VectorizedDF
  from sktime.datatypes._utilities import get_time_index
  from sktime.utils.validation.series import check_time_index, is_integer_index
label_desc: Use image node_id 9 for calling a global function with example usage: _shift(x, by, return_index) and returns: unknown, unknown, idx