code: def _get_test_objects(
      self,
      task_type,
      task_id,
      num_gpus=0,
      communication=CollectiveCommunication.AUTO,
      use_strategy_object=False,
      local_mode=False,
  ):
      collective_keys = cross_device_utils.CollectiveKeys(
          group_key_start=10
          + CollectiveAllReduceTest.collective_key_base
      )
      if local_mode:
          if num_gpus:
              devices = ["/device:GPU:%d" % i for i in range(num_gpus)]
          else:
              devices = ["/device:CPU:0"]
  
          comm_options = collective_util.Options(
              implementation=communication
          )
          if use_strategy_object:
              strategy = mwms_lib.CollectiveAllReduceStrategy._from_local_devices(
                  devices, comm_options
              )  # pylint: disable=protected-access
              return strategy, devices, ""
          else:
              collective_all_reduce_ops = (
                  cross_device_ops_lib.CollectiveAllReduce(
                      devices=devices,
                      group_size=len(devices),
                      options=comm_options,
                      collective_keys=collective_keys,
                  )
              )
              return collective_all_reduce_ops, devices, ""
      else:
          # NCCL requires physical GPUs for every replica, which we can't do with
          # simulated multi host set up now.
          assert communication != CollectiveCommunication.NCCL
          if num_gpus:
              devices = [
                  "/job:%s/task:%d/replica:0/device:GPU:%d"
                  % (task_type, task_id, i)
                  for i in range(num_gpus)
              ]
          else:
              devices = [
                  "/job:%s/task:%d/replica:0/device:CPU:0"
                  % (task_type, task_id)
              ]
  
          comm_options = collective_util.Options(
              implementation=communication
          )
          if use_strategy_object:
              resolver = cluster_resolver.SimpleClusterResolver(
                  cluster_spec=multi_worker_util.normalize_cluster_spec(
                      self._cluster_spec
                  ),
                  task_type=task_type,
                  task_id=task_id,
                  num_accelerators={"GPU": num_gpus},
              )
              strategy = mwms_lib.CollectiveAllReduceStrategy(
                  communication_options=comm_options,
                  cluster_resolver=resolver,
              )
              return (
                  strategy,
                  devices,
                  "grpc://" + self._cluster_spec[task_type][task_id],
              )
          else:
              collective_all_reduce_ops = (
                  cross_device_ops_lib.CollectiveAllReduce(
                      devices=devices,
                      group_size=len(devices) * NUM_WORKERS,
                      options=comm_options,
                      collective_keys=collective_keys,
                  )
              )
              return (
                  collective_all_reduce_ops,
                  devices,
                  "grpc://" + self._cluster_spec[task_type][task_id],
              )
  
imports: import itertools
  import os
  import threading
  import time
  from absl.testing import parameterized
  import numpy
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.python.distribute import cluster_resolver
  from tensorflow.python.distribute import collective_all_reduce_strategy
  from tensorflow.python.distribute import collective_util
  from tensorflow.python.distribute import combinations
  from tensorflow.python.distribute import cross_device_ops
  from tensorflow.python.distribute import cross_device_utils
  from tensorflow.python.distribute import device_util
  from tensorflow.python.distribute import distribute_utils
  from tensorflow.python.distribute import multi_worker_test_base
  from tensorflow.python.distribute import multi_worker_util
  from tensorflow.python.distribute import reduce_util
  from tensorflow.python.distribute import strategy_combinations
  from tensorflow.python.distribute import values
  from tensorflow.python.eager import context
  from tensorflow.python.eager import test
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import kernels
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import collective_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import variables
label_desc: Use image node_id 3 for calling the CollectiveAllReduceTest obj's underlying member method code with example usage: obj._get_test_objects(task_type, task_id, num_gpus, communication, use_strategy_object, local_mode) and returns: strategy,  devices,  str, collective_all_reduce_ops,  devices,  str, strategy,  devices,  unknown, collective_all_reduce_ops,  devices,  unknown