code: def test_validate_shards_shape_change(self):
      root = module.Module()
      with ops.device("cpu:0"):
          v0 = resource_variable_ops.ResourceVariable(
              [[0.0, 1.0]], name="v0"
          )
      root.v0 = v0
  
      class ShapeChangeCallback(sharding_util.ShardingCallback):
          @property
          def description(self):
              return "shape change callback"
  
          def __call__(
              self,
              shardable_tensors: Sequence[
                  sharding_util.ShardableTensor
              ],
          ) -> Sequence[sharding_util.TensorSliceDict]:
              shards = []
              for shardable_tensor in shardable_tensors:
                  tensor = shardable_tensor.tensor
                  checkpoint_key = shardable_tensor.checkpoint_key
                  slice_spec = shardable_tensor.slice_spec
                  if checkpoint_key == "v0/.ATTRIBUTES/VARIABLE_VALUE":
                      tensor = array_ops.transpose(tensor)
                  shards.append({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 = ShapeChangeCallback()
      shards = []
      for tensors in shardable_tensors:
          shards.extend(sharding_callback(tensors))
  
      with self.assertRaisesRegex(
          RuntimeError, "a tensor was found with an altered shape"
      ):
          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 6 for calling the ShardingUtilTest obj's underlying member method code with example usage: obj.test_validate_shards_shape_change() and returns: str, shards