code: def run_tf_dataset_multigpu_eager_mirrored_strategy(
      get_pipeline_desc=get_image_pipeline, to_dataset=to_image_dataset
  ):
      num_devices = num_available_gpus()
      batch_size = 8
      num_threads = 4
      iterations = 8
  
      strategy = tf.distribute.MirroredStrategy(
          devices=available_gpus()
      )
      input_options = tf.distribute.InputOptions(
          experimental_place_dataset_on_device=True,
          experimental_fetch_to_device=False,
          experimental_replication_mode=tf.distribute.InputReplicationMode.PER_REPLICA,
      )
  
      def dataset_fn(input_context):
          return get_dali_dataset(
              batch_size,
              num_threads,
              "gpu",
              input_context.input_pipeline_id,
              num_devices,
              get_pipeline_desc=get_pipeline_desc,
              to_dataset=to_dataset,
          )
  
      dali_datasets = [
          strategy.distribute_datasets_from_function(
              dataset_fn, input_options
          )
      ]
      dataset_results = run_dataset_eager_mode(
          dali_datasets, iterations
      )
  
      standalone_pipelines = []
      for device_id in range(num_devices):
          pipeline, _, _ = get_pipeline_desc(
              batch_size,
              num_threads,
              device="gpu",
              device_id=device_id,
              shard_id=device_id,
              num_shards=num_devices,
          )
          standalone_pipelines.append(pipeline)
  
      standalone_results = run_pipeline(
          standalone_pipelines, iterations, "gpu"
      )
  
      dataset_results = per_replica_to_numpy(
          dataset_results, num_devices
      )
      compare(
          dataset_results, standalone_results, iterations, num_devices
      )
  
imports: import math
  import numpy
  import nvidia.dali.fn
  import nvidia.dali.plugin.tf
  import nvidia.dali.types
  import os
  import tensorflow
  from contextlib import contextmanager
  from nose import SkipTest
  from nvidia.dali.pipeline import Pipeline
  from tensorflow.python.client import device_lib
  from test_utils import to_array, get_dali_extra_path
label_desc: Use image node_id 21 for calling a global function with example usage: run_tf_dataset_multigpu_eager_mirrored_strategy(get_pipeline_desc, to_dataset) and returns: get_dali_dataset