code: def get_slice(
      obj,
      start=None,
      end=None,
      start_inclusive=True,
      end_inclusive=False,
  ):
      """Slice obj with start (inclusive) and end (exclusive) indices.
  
      Returns time series or time series panel with time indices
          strictly greater and equal to start index and less than
          end index.
  
      Parameters
      ----------
      obj : sktime compatible time series data container or None
          if not None, 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_WINDOW_SUPPORTED_MTYPES
      start : int or timestamp, optional, default = None
          must be int if obj is int indexed, timestamp if datetime indexed
          Inclusive start of slice. Default = None.
          If None, then no slice at the start
      end : int or timestamp, optional, default = None
          must be int if obj is int indexed, timestamp if datetime indexed
          Exclusive end of slice. Default = None
          If None, then no slice at the end
      start_inclusive : bool, optional, default = True
          whether start index is inclusive (True) or not (False)
      end_inclusive : bool, optional, default = False
          whether end index is inclusive (True) or not (False)
  
      Returns
      -------
      obj sub-set sliced for `start` to `end`, default is start/inclusive, end/exclusive
          contains all indices from `start` (in- or exclusive as per `start_inclusive`)
          up until `end` (in- or exclusive as per `end_inclusive`)
          None if obj was None
      """
      from sktime.datatypes import check_is_scitype, convert_to
  
      if (start is None and end is None) or obj is None:
          return obj
  
      valid, _, metadata = check_is_scitype(
          obj,
          scitype=["Series", "Panel", "Hierarchical"],
          return_metadata=True,
      )
      if not valid:
          raise ValueError(
              "obj must be of Series, Panel, or Hierarchical scitype"
          )
      obj_in_mtype = metadata["mtype"]
  
      obj = convert_to(obj, GET_WINDOW_SUPPORTED_MTYPES)
  
      # numpy3D (Panel) or np.npdarray (Series)
      # Assumes the index is integer so will be exclusive by default
      if isinstance(obj, np.ndarray):
          # if 2D or 3D, we need to subset by last, not first dimension
          # if 1D, we need to subset by first dimension
          # to achieve that effect, we swap first and last in case of 2D, 3D
          # and always subset on first dimension
          if obj.ndim > 1:
              obj = obj.swapaxes(1, -1)
          # deal with inclusive/exclusive
          if not start_inclusive:
              start = start + 1
          if end_inclusive:
              end = end + 1
          # deal with out-of-index
          if start < 0:
              start = 0
          if start >= len(obj):
              start = len(obj) - 1
          # subsetting
          if start and end:
              obj_subset = obj[start:end]
          elif end:
              obj_subset = obj[:end]
          else:
              obj_subset = obj[start:]
          # we need to swap first and last dimension back before returning, if done above
          if obj.ndim > 1:
              obj_subset = obj_subset.swapaxes(1, -1)
          return obj_subset
  
      # pd.DataFrame(Series), pd-multiindex (Panel) and pd_multiindex_hier (Hierarchical)
      # Assumes the index is pd.Timestamp or pd.Period and ensures the end is
      # exclusive with slice_select
      if isinstance(obj, pd.DataFrame):
          if not isinstance(obj.index, pd.MultiIndex):
              time_indices = obj.index
          else:
              time_indices = obj.index.get_level_values(-1)
  
          def get_start_cond():
              if start_inclusive:
                  return time_indices >= start
              else:
                  return time_indices > start
  
          def get_end_cond():
              if end_inclusive:
                  return time_indices <= end
              else:
                  return time_indices < end
  
          if start and end:
              slice_select = get_start_cond() & get_end_cond()
          elif end:
              slice_select = get_end_cond()
          elif start:
              slice_select = get_start_cond()
  
          obj_subset = obj.iloc[slice_select]
          return convert_to(obj_subset, obj_in_mtype)
  
      raise ValueError(
          "bug in get_slice, unreachable condition, ifs should be exhaustive"
      )
  
file_path: sktime/sktime/datatypes/_utilities.py
imports: import numpy
  import pandas
label_desc: Use image node_id 8 for calling a global function with example usage: get_slice(obj, start, end, start_inclusive, end_inclusive) and returns: obj, obj_subset, convert_to, unknown, unknown, unknown, unknown