code: def _slice(
      data: np.ndarray,
      starts: np.ndarray,
      ends: np.ndarray,
      axes: Optional[np.ndarray] = None,
      steps: Optional[np.ndarray] = None,
  ) -> np.ndarray:
      if isinstance(starts, list):
          starts = np.array(starts)
      if isinstance(ends, list):
          ends = np.array(ends)
      if isinstance(axes, list):
          axes = np.array(axes)
      if isinstance(steps, list):
          steps = np.array(steps)
      if len(starts.shape) == 0:
          starts = np.array([starts])
      if len(ends.shape) == 0:
          ends = np.array([ends])
      if axes is None:
          if steps is None:
              slices = [slice(s, e) for s, e in zip(starts, ends)]
          else:
              slices = [
                  slice(s, e, d) for s, e, d in zip(starts, ends, steps)
              ]
      else:  # noqa: PLR5501
          if steps is None:
              slices = [slice(0, a) for a in data.shape]
              for s, e, a in zip(starts, ends, axes):
                  slices[a] = slice(s, e)
          else:
              slices = [slice(0, a) for a in data.shape]
              for s, e, a, d in zip(starts, ends, axes, steps):
                  slices[a] = slice(s, e, d)
      try:
          return data[tuple(slices)]  # type: ignore
      except TypeError as e:  # pragma: no cover
          raise TypeError(
              f"Unable to extract slice {slices!r} for shape {data.shape!r}."
          ) from e
  
file_path: onnx/onnx/reference/ops/op_slice.py
imports: from typing import Optional
  import numpy
  from onnx.reference.ops._op import OpRun
label_desc: Use image node_id 1 for calling a global function with example usage: _slice(data, starts, ends, axes, steps) and returns: data