code: def _get_multi_worker_mirrored_creator(
      required_gpus, use_merge_call=True
  ):
      def _create_multi_worker_mirrored():
          tf_config = cluster_resolver.TFConfigClusterResolver()
          master = tf_config.master()
          if tf_config.rpc_layer:
              # Strip off the rpc_layer suffix.
              master = master[len("%s://" % tf_config.rpc_layer) :]
          resolver = cluster_resolver.SimpleClusterResolver(
              cluster_spec=tf_config.cluster_spec(),
              task_type=tf_config.task_type,
              task_id=tf_config.task_id,
              master=master,
              environment=tf_config.environment,
              num_accelerators={"GPU": required_gpus},
              rpc_layer=tf_config.rpc_layer or "grpc",
          )
          # Disable health check and coordination service. We don't have a reliable
          # way to shutdown the strategy (and thus the strategy health check or
          # coordination service heartbeat) at the end of a test. Turning on the
          # strategy health check or coordination service heartbeat causes some
          # flakiness since we re-create part of the server when creating a strategy,
          # and our tests are capable of handling failures.
          CollectiveAllReduceExtended._enable_check_health = (  # pylint: disable=protected-access
              False
          )
          context.context().configure_coordination_service(
              service_type=""
          )
          # Always create the strategy in eager mode so that it starts the server and
          # configures the eager context. The eager context can no longer be
          # configured after initialization.
          with context.eager_mode():
              strategy = CollectiveAllReduceStrategy(
                  cluster_resolver=resolver
              )
  
          if not use_merge_call:
              strategy.extended._use_merge_call = (
                  lambda: False
              )  # pylint: disable=protected-access
          # TODO(b/152320929): Wait for the cluster before proceeding, otherwise
          # collectives may hang if any worker launches collectives before the chief
          # creates the strategy.
          try:
              multi_process_runner.get_barrier().wait()
          except ValueError:
              # If the creator is called in the main process,
              # multi_process_runner.get_barrier() raises ValueError, which is safe to
              # ignore.
              pass
          return strategy
  
      def skip_if_cannot_start_grpc_server():
          try:
              return _create_multi_worker_mirrored()
          except errors.UnknownError as e:
              if "Could not start gRPC server" in e.message and (
                  len(sys.argv) >= 1 and "bazel" in sys.argv[0]
              ):
                  raise unittest.SkipTest("Cannot start std servers.")
              else:
                  raise
  
      return skip_if_cannot_start_grpc_server
  
imports: import sys
  import unittest
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.python import tf2
  from tensorflow.python.distribute import central_storage_strategy
  from tensorflow.python.distribute import cluster_resolver
  from tensorflow.python.distribute import collective_all_reduce_strategy
  from tensorflow.python.distribute import combinations
  from tensorflow.python.distribute import distribute_lib
  from tensorflow.python.distribute import mirrored_strategy
  from tensorflow.python.distribute import multi_process_runner
  from tensorflow.python.distribute import multi_worker_test_base
  from tensorflow.python.distribute import one_device_strategy
  from tensorflow.python.distribute import parameter_server_strategy_v2
  from tensorflow.python.distribute import sharded_variable
  from tensorflow.python.distribute import test_util
  from tensorflow.python.distribute import tpu_strategy
  from tensorflow.python.distribute.cluster_resolver import tpu_cluster_resolver
  from tensorflow.python.eager import context
  from tensorflow.python.eager import remote
  from tensorflow.python.framework import device
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import test_util
  from tensorflow.python.platform import flags
  from tensorflow.python.tpu import device_assignment
  from tensorflow.python.training import server_lib
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 5 for calling a global function with example usage: _get_multi_worker_mirrored_creator(required_gpus, use_merge_call) and returns: skip_if_cannot_start_grpc_server, strategy, _create_multi_worker_mirrored