code: def DALIIteratorWrapper(
      pipeline=None,
      serialized_pipeline=None,
      sparse=[],
      shapes=[],
      dtypes=[],
      batch_size=-1,
      prefetch_queue_depth=2,
      **kwargs,
  ):
      """
      TF Plugin Wrapper
  
      This operator works in the same way as DALI TensorFlow plugin, with the exception that it also
      accepts Pipeline objects as an input, which are serialized internally. For more information,
      see :meth:`nvidia.dali.plugin.tf.DALIRawIterator`.
      """
      if type(prefetch_queue_depth) is dict:
          exec_separated = True
          cpu_prefetch_queue_depth = prefetch_queue_depth["cpu_size"]
          gpu_prefetch_queue_depth = prefetch_queue_depth["gpu_size"]
      elif type(prefetch_queue_depth) is int:
          exec_separated = False
          cpu_prefetch_queue_depth = -1  # dummy: wont' be used
          gpu_prefetch_queue_depth = prefetch_queue_depth
  
      if serialized_pipeline is None:
          serialized_pipeline = serialize_pipeline(pipeline)
  
      # if batch_size is not provided we need to extract if from the shape arg
      if (
          not isinstance(shapes, Iterable) or len(shapes) == 0
      ) and batch_size == -1:
          raise Exception(
              "shapes and batch_size arguments cannot be empty, "
              "please provide at leas one shape argument element with the BATCH size "
              "or set batch_size"
          )
  
      if len(sparse) > 0 and sparse[0] and batch_size == -1:
          if isinstance(shapes[0], Iterable) and len(shapes[0]) == 1:
              shapes[0] = (shapes[0][0], 1)
          else:
              shapes[0] = (shapes[0], 1)
  
      # shapes and dtypes need to take into account that sparse tensor will produce 3 output tensors
      new_dtypes = []
      new_shapes = []
      for i in range(len(dtypes)):
          if i < len(sparse) and sparse[i]:
              # indices type of sparse tensor is tf.int64
              new_dtypes.append(tf.int64)
              new_dtypes.append(dtypes[i])
              # dense shape type of sparse tensor is tf.int64
              new_dtypes.append(tf.int64)
              if len(shapes) > i and len(shapes[i]) > 0:
                  new_shapes.append((shapes[i][0], 1))
                  new_shapes.append((shapes[i][0]))
              else:
                  new_shapes.append(())
                  new_shapes.append(())
              new_shapes.append(())
          else:
              new_dtypes.append(dtypes[i])
              if len(shapes) > i:
                  new_shapes.append(shapes[i])
  
      # gpu_prefetch_queue_depth correspond to the global queue depth in the uniform case
      out = _dali_tf(
          serialized_pipeline=serialized_pipeline,
          shapes=new_shapes,
          dtypes=new_dtypes,
          sparse=sparse,
          batch_size=batch_size,
          exec_separated=exec_separated,
          gpu_prefetch_queue_depth=gpu_prefetch_queue_depth,
          cpu_prefetch_queue_depth=cpu_prefetch_queue_depth,
          **kwargs,
      )
      new_out = []
      j = 0
      for i in range(len(dtypes)):
          if i < len(sparse) and sparse[i]:
              new_out.append(
                  tf.SparseTensor(
                      indices=out[j],
                      values=out[j + 1],
                      dense_shape=out[j + 2],
                  )
              )
              j += 3
          else:
              new_out.append(out[j])
              j += 1
      return new_out
  
imports: import sys
  import tensorflow
  from tensorflow.python.data.util import nest
  from tensorflow.python.framework import tensor_shape
  from nvidia.dali import types
  from nvidia.dali import internal
  from nvidia.dali.external_source import _is_external_source, _has_external_source
  from nvidia.dali.external_source import _is_external_source_with_callback
  from nvidia.dali._utils.external_source_impl import _get_generator_from_source_desc
  from nvidia.dali._utils.external_source_impl import _cycle_enabled
  from distutils.version import LooseVersion
  import warnings
  from nvidia.dali_tf_plugin import dali_tf_plugin
  from collections.abc import Mapping, Iterable
label_desc: Use image node_id 2 for calling a global function with example usage: DALIIteratorWrapper(pipeline, serialized_pipeline, sparse, shapes, dtypes, batch_size, prefetch_queue_depth) and returns: new_out