code: def testCollectiveGatherShapeMismatch(self):
      group_key = 1
      instance_key = 1
      t0 = [1, 2, 3, 4]
      t1 = [5, 6, 7, 8]
      t2 = [9, 10]
      # Tests that execute collectives need to be enclosed in graph or tf.function
      with ops.Graph().as_default():
          with self.session(
              config=config_pb2.ConfigProto(device_count={"CPU": 2})
          ) as sess:
              with ops.device("/CPU:0"):
                  in0 = constant_op.constant(t0)
                  c0 = collective_ops.all_gather(
                      in0, 2, group_key, instance_key
                  )
              with ops.device("/CPU:1"):
                  in1 = constant_op.constant(t1)
                  in2 = constant_op.constant(t2)
                  c1 = collective_ops.all_gather(
                      in1, 2, group_key, instance_key
                  )
                  c2 = collective_ops.all_gather(
                      in2, 2, group_key, instance_key
                  )
              run_options = config_pb2.RunOptions()
              run_options.experimental.collective_graph_key = 1
              sess.run([c0, c1], options=run_options)
              with self.assertRaisesRegex(
                  errors.InvalidArgumentError, "Shape mismatch"
              ):
                  sess.run([c0, c2], options=run_options)
  
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 22 for calling the CollectiveOpTest obj's underlying member method code with example usage: obj.testCollectiveGatherShapeMismatch() without return types