code: def external_source_pipeline(
      data_path,
      batch_size,
      num_threads,
      device_id,
      prefetch_queue_depth,
      reader_queue_depth,
      read_encoded,
      source_mode,
      **kwargs,
  ):
      pipe = ExternalSourcePipeline(
          batch_size=batch_size,
          num_threads=num_threads,
          device_id=device_id,
          prefetch_queue_depth=prefetch_queue_depth,
          data_path=data_path,
          source_mode=source_mode,
          read_encoded=read_encoded,
      )
      with pipe:
          images, labels = dali.fn.external_source(
              pipe.loader,
              num_outputs=2,
              batch=source_mode != "sample",
              cycle="raise" if source_mode == "generator" else None,
              batch_info=source_mode == "batch",
          )
          if read_encoded:
              images = dali.fn.decoders.image(
                  images, device="mixed", output_type=types.RGB
              )
          images = common_pipeline(images.gpu())
          pipe.set_outputs(images, labels)
      return pipe
  
imports: import argparse
  import cv2
  import numpy
  import nvidia.dali
  import nvidia.dali.types
  import os
label_desc: Use image node_id 4 for calling a global function with example usage: external_source_pipeline(data_path, batch_size, num_threads, device_id, prefetch_queue_depth, reader_queue_depth, read_encoded, source_mode) and returns: pipe