code: def testCollectiveTensorsHaveNoDeviceSpecified(self):
      cpus = config.list_physical_devices("CPU")
      self.assertEqual(len(cpus), 1)
      config.set_logical_device_configuration(
          cpus[0],
          [
              context.LogicalDeviceConfiguration(),
              context.LogicalDeviceConfiguration(),
          ],
      )
      context.ensure_initialized()
  
      group_size = 2
      group_key = 1
      instance_key = 1
  
      @def_function.function
      def fn(all_args):
          results = []
          # The inputs have no devices set. This is expected to be a trace-time
          # check only.
          self.assertEqual(all_args[0].device, "")
          self.assertEqual(all_args[1].device, "")
  
          with ops.device("/CPU:0"):
              results.append(
                  collective_ops.all_reduce(
                      all_args[0],
                      group_size,
                      group_key,
                      instance_key,
                      "Add",
                      "Div",
                  )
              )
          with ops.device("/CPU:1"):
              results.append(
                  collective_ops.all_reduce(
                      all_args[1],
                      group_size,
                      group_key,
                      instance_key,
                      "Add",
                      "Div",
                  )
              )
  
          return results
  
      with ops.device("/CPU:0"):
          in0 = constant_op.constant(1)
      with ops.device("/CPU:1"):
          in1 = constant_op.constant(3)
      result = fn([in0, in1])
      self.assertAllClose(result, [2, 2])
  
imports: import time
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.core.protobuf import rewriter_config_pb2
  from tensorflow.python.eager import context
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import config
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import kernels
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  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 variable_v1
  from tensorflow.python.ops import variables
  from tensorflow.python.ops import while_loop
  from tensorflow.python.platform import test
  from tensorflow.python.platform import tf_logging
label_desc: Use image node_id 27 for calling the CollectiveOpTest obj's underlying member method code with example usage: obj.testCollectiveTensorsHaveNoDeviceSpecified() and returns: results