code: def create_stacking_pipeline(
      callback,
      py_callback_pickler,
      batch_size,
      parallel=True,
      py_num_workers=None,
      py_start_method="spawn",
  ):
      extra = {}
      if parallel:
          extra["py_num_workers"] = py_num_workers
          extra["py_start_method"] = py_start_method
          if py_callback_pickler is not None:
              extra["py_callback_pickler"] = py_callback_pickler
  
      @pipeline_def(
          batch_size=batch_size, num_threads=2, device_id=0, **extra
      )
      def create_pipline():
          jpegs = fn.external_source(
              source=callback,
              num_outputs=sequence_lenght * 2,
              parallel=parallel,
              batch=False,
          )
          images = fn.decoders.image(jpegs, device="cpu")
          sequence = fn.stack(*images)
          sequence = fn.reshape(sequence, layout="DHWC")
          return sequence
  
      return create_pipline()
  
imports: import copyreg
  import numpy
  import nvidia.dali.fn
  import nvidia.dali.pickling
  import os
  from nvidia.dali import pipeline_def
  from pickle import PicklingError
  from nose_utils import raises
  from test_utils import get_dali_extra_path, restrict_python_version
label_desc: Use image node_id 18 for calling a global function with example usage: create_stacking_pipeline(callback, py_callback_pickler, batch_size, parallel, py_num_workers, py_start_method) and returns: create_pipline, sequence