code: def element_extract_pipe(shape, layout, element_map, dev, dtype):
      min_shape = [s // 2 if s > 1 else 1 for s in shape]
      min_shape[0] = shape[0]
      min_shape = tuple(min_shape)
      input = fn.external_source(
          source=RandomlyShapedDataIterator(
              batch_size,
              min_shape=min_shape,
              max_shape=shape,
              dtype=dtype,
          ),
          layout=layout,
      )
      if dev == "gpu":
          input = input.gpu()
      elements = fn.element_extract(input, element_map=element_map)
      result = (
          (input,) + tuple(elements)
          if len(element_map) > 1
          else (input, elements)
      )
      return result
  
file_path: DALI/dali/test/python/operator_1/test_element_extract.py
imports: from nvidia.dali.pipeline import Pipeline
  from nvidia.dali import fn, pipeline_def
  import nvidia.dali.ops
  from test_utils import RandomlyShapedDataIterator, to_array
  from nose_utils import assert_raises
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: element_extract_pipe(shape, layout, element_map, dev, dtype) and returns: result