code: def mnist_pipeline(
      num_threads,
      path,
      device,
      device_id=0,
      shard_id=0,
      num_shards=1,
      seed=0,
  ):
      pipeline = Pipeline(BATCH_SIZE, num_threads, device_id, seed)
      with pipeline:
          jpegs, labels = fn.readers.caffe2(
              path=path,
              random_shuffle=True,
              shard_id=shard_id,
              num_shards=num_shards,
          )
          images = fn.decoders.image(
              jpegs,
              device="mixed" if device == "gpu" else "cpu",
              output_type=types.GRAY,
          )
          if device == "gpu":
              labels = labels.gpu()
          images = fn.crop_mirror_normalize(
              images,
              dtype=types.FLOAT,
              mean=[0.0],
              std=[255.0],
              output_layout="CHW",
          )
  
          pipeline.set_outputs(images, labels)
  
      return pipeline
  
imports: import nvidia.dali.plugin.tf
  import os
  from nvidia.dali.pipeline import Pipeline
  import nvidia.dali.fn
  import nvidia.dali.types
  from test_utils_tensorflow import num_available_gpus
  from shutil import rmtree
  import tensorflow
  import tensorflow.compat.v1
label_desc: Use image node_id 1 for calling a global function with example usage: mnist_pipeline(num_threads, path, device, device_id, shard_id, num_shards, seed) and returns: pipeline