code: def test_validate_shards_duplicate_tensor(self):
      root = module.Module()
      with ops.device("cpu:0"):
          v0 = resource_variable_ops.ResourceVariable(0.0, name="v0")
      with ops.device("cpu:1"):
          v1 = resource_variable_ops.ResourceVariable(1.0, name="v1")
      root.v0 = v0
      root.v1 = v1
  
      class DuplicateTensorCallback(sharding_util.ShardingCallback):
          @property
          def description(self):
              return "duplicate tensor callback"
  
          def __call__(
              self,
              shardable_tensors: Sequence[
                  sharding_util.ShardableTensor
              ],
          ) -> Sequence[sharding_util.TensorSliceDict]:
              tensor = shardable_tensors[0].tensor
              checkpoint_key = shardable_tensors[0].checkpoint_key
              slice_spec = shardable_tensors[0].slice_spec
              shards = [
                  {checkpoint_key: {slice_spec: tensor}},
                  {checkpoint_key: {slice_spec: tensor}},
              ]
              return shards
  
      shardable_tensors = self._get_shardable_tensors_by_task(root)
      shardable_tensors_flat = []
      for tensors in shardable_tensors:
          shardable_tensors_flat.extend(tensors)
  
      sharding_callback = DuplicateTensorCallback()
      shards = []
      for tensors in shardable_tensors:
          shards.extend(sharding_callback(tensors))
  
      with self.assertRaisesRegex(
          RuntimeError,
          "multiple tensors with the same checkpoint "
          "key and slice spec were found",
      ):
          sharding_util.validate_shards(
              shards,
              shardable_tensors_flat,
              sharding_callback.description,
          )
  
imports: from typing import Sequence
  from tensorflow.python.checkpoint import checkpoint
  from tensorflow.python.checkpoint import graph_view
  from tensorflow.python.checkpoint.sharding import sharding_policies
  from tensorflow.python.checkpoint.sharding import sharding_util
  from tensorflow.python.eager import remote
  from tensorflow.python.eager import test
  from tensorflow.python.framework import device
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.module import module
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.training import server_lib
  from tensorflow.python.training.saving import saveable_object
  from tensorflow.python.training.saving import saveable_object_util
label_desc: Use image node_id 4 for calling the ShardingUtilTest obj's underlying member method code with example usage: obj.test_validate_shards_duplicate_tensor() and returns: str, shards