code: def get_iterable_from_iterable_or_generator(
      source_desc: SourceDescription, is_batched
  ):
      """Wrap iterable or generator function into another iterable while peeking the first element
  
      If the source is generator function it must be called first.
      """
      if source_desc.kind == SourceKind.GENERATOR_FUNC:
          first_iter = iter(source_desc.source())
      else:
          first_iter = iter(source_desc.source)
      first = next(first_iter)
      dtype, shape = _inspect_data(first, is_batched)
  
      class PeekFirstGenerator:
          first_iterator = first_iter
          first_value = first
  
          def __init__(self):
              self.source = source_desc.source
  
          def __iter__(self):
              if PeekFirstGenerator.first_iterator is not None:
                  self.it = PeekFirstGenerator.first_iterator
                  PeekFirstGenerator.first_iterator = None
              else:
                  if source_desc.kind == SourceKind.GENERATOR_FUNC:
                      self.it = iter(source_desc.source())
                  else:
                      self.it = iter(source_desc.source)
              return self
  
          def __next__(self):
              if PeekFirstGenerator.first_value is not None:
                  result = PeekFirstGenerator.first_value
                  PeekFirstGenerator.first_value = None
              else:
                  result = next(self.it)
              if is_batched:
                  return batch_to_numpy(
                      result,
                      _tf_batch_error_msg,
                      non_uniform_str=_tf_uniform_error_msg,
                  )
              else:
                  return sample_to_numpy(result, _tf_sample_error_msg)
  
      return PeekFirstGenerator, dtype, shape
  
imports: from enum import Enum
  from nvidia.dali import types
  from nvidia.dali import tensors
  import inspect
  import functools
label_desc: Use image node_id 14 for calling a global function with example usage: get_iterable_from_iterable_or_generator(source_desc, is_batched) and returns: PeekFirstGenerator,  dtype,  shape, self, batch_to_numpy, sample_to_numpy