code: def run_slices(file_like, repeat=3, offset=0, order="F"):
      arr = np.arange(np.prod(SHAPE)).reshape(SHAPE)
      n_dim = len(SHAPE)
      n_slicers = len(_slices_for_len(1))
      times_arr = np.zeros((n_dim, n_slicers))
      with ImageOpener(file_like, "wb") as fobj:
          fobj.write(b"\0" * offset)
          fobj.write(arr.tobytes(order=order))
      with ImageOpener(file_like, "rb") as fobj:
          for i, L in enumerate(SHAPE):
              for j, slicer in enumerate(_slices_for_len(L)):
                  sliceobj = [slice(None)] * n_dim
                  sliceobj[i] = slicer
  
                  def f():
                      fileslice(
                          fobj,
                          tuple(sliceobj),
                          arr.shape,
                          arr.dtype,
                          offset,
                          order,
                      )
  
                  times_arr[i, j] = timeit(f, number=repeat)
  
          def g():
              fobj.seek(offset)
              data = fobj.read()
              np.ndarray(SHAPE, arr.dtype, buffer=data, order=order)
  
          base_time = timeit(g, number=repeat)
      return times_arr, base_time
  
file_path: nibabel/nibabel/benchmarks/bench_fileslice.py
imports: import sys
  from io import BytesIO
  from timeit import timeit
  import numpy
  from ..fileslice import fileslice
  from ..openers import ImageOpener
  from ..optpkg import optional_package
  from ..rstutils import rst_table
  from ..tmpdirs import InTemporaryDirectory
label_desc: Use image node_id 2 for calling a global function with example usage: run_slices(file_like, repeat, offset, order) and returns: times_arr,  base_time