code: def slice_func_helper(
      axes,
      axis_names,
      layout,
      normalized_anchor,
      normalized_shape,
      image,
      slice_anchor,
      slice_shape,
  ):
      # TODO(janton): remove this
      if not axes and not axis_names:
          axis_names = "WH"
  
      if axis_names:
          axes = []
          for axis_name in axis_names:
              assert axis_name in layout
              axis_pos = layout.find(axis_name)
              axes.append(axis_pos)
  
      shape = image.shape
      full_slice_anchor = [0] * len(shape)
      full_slice_shape = list(shape)
      for axis in axes:
          idx = axes.index(axis)
          full_slice_anchor[axis] = slice_anchor[idx]
          full_slice_shape[axis] = slice_shape[idx]
  
      start, end, _ = abs_slice_start_and_end(
          shape,
          full_slice_anchor,
          full_slice_shape,
          normalized_anchor,
          normalized_shape,
      )
  
      if len(full_slice_anchor) == 1:
          return image[start[0] : end[0]]
      elif len(full_slice_anchor) == 2:
          return image[start[0] : end[0], start[1] : end[1]]
      elif len(full_slice_anchor) == 3:
          return image[
              start[0] : end[0], start[1] : end[1], start[2] : end[2]
          ]
      elif len(full_slice_anchor) == 4:
          return image[
              start[0] : end[0],
              start[1] : end[1],
              start[2] : end[2],
              start[3] : end[3],
          ]
      else:
          assert False
  
imports: from nvidia.dali import Pipeline, pipeline_def, ops, fn, types
  import numpy
  import os
  from functools import partial
  from math import floor
  from test_utils import compare_pipelines, get_dali_extra_path, RandomDataIterator, generator_random_axes_for_3d_input, generator_random_data, as_array
  from nose_utils import assert_raises
  from nose2.tools import params
label_desc: Use image node_id 3 for calling a global function with example usage: slice_func_helper(axes, axis_names, layout, normalized_anchor, normalized_shape, image, slice_anchor, slice_shape) and returns: image, image, image, image