code: def test_MaxShardSizePolicy_Strings(self):
      v_strings = [
          "".join(
              random.choices(
                  string.ascii_uppercase + string.digits, k=10
              )
          )
          for _ in range(4)
      ]
  
      root = module.Module()
      with ops.device("cpu:0"):
          v0 = resource_variable_ops.ResourceVariable(
              v_strings, name="v0", dtype=dtypes.string
          )
      self.evaluate(v0.initializer)
      root.v0 = v0
  
      v0_name = "v0/.ATTRIBUTES/VARIABLE_VALUE"
  
      class V0SaveSliceInfo(variables.Variable.SaveSliceInfo):
          def __init__(self, var_offset, var_shape):
              super().__init__(
                  full_name=v0_name,
                  full_shape=tensor_shape.TensorShape(dims=[4]),
                  var_offset=var_offset,
                  var_shape=var_shape,
              )
  
      shardable_tensors = self._get_shardable_tensors_by_task(root)
  
      # Test sharding the v0 & v1 tensors with different max shard sizes.
  
      # max_shard_size: 10 bytes
      # Each string in v0 is 10 bytes, so there should be 1 string per shard.
      callback = sharding_policies.MaxShardSizePolicy(max_shard_size=10)
      shards = []
      for tensors in shardable_tensors:
          shards.extend(callback(tensors))
  
      self.assertEqual(
          [set(shard.keys()) for shard in shards],
          [
              {
                  "v0/.ATTRIBUTES/VARIABLE_VALUE",
              },
              {
                  "v0/.ATTRIBUTES/VARIABLE_VALUE",
              },
              {
                  "v0/.ATTRIBUTES/VARIABLE_VALUE",
              },
              {
                  "v0/.ATTRIBUTES/VARIABLE_VALUE",
              },
              {
                  "_CHECKPOINTABLE_OBJECT_GRAPH",
              },
          ],
      )
  
      slice_spec = V0SaveSliceInfo(var_offset=[0], var_shape=[1]).spec
      self.assertAllEqual(
          self.evaluate(shards[0][v0_name][slice_spec]), [v_strings[0]]
      )
  
      slice_spec = V0SaveSliceInfo(var_offset=[1], var_shape=[1]).spec
      self.assertAllEqual(
          self.evaluate(shards[1][v0_name][slice_spec]), [v_strings[1]]
      )
  
      slice_spec = V0SaveSliceInfo(var_offset=[2], var_shape=[1]).spec
      self.assertAllEqual(
          self.evaluate(shards[2][v0_name][slice_spec]), [v_strings[2]]
      )
  
      slice_spec = V0SaveSliceInfo(var_offset=[3], var_shape=[1]).spec
      self.assertAllEqual(
          self.evaluate(shards[3][v0_name][slice_spec]), [v_strings[3]]
      )
  
imports: import random
  import string
  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_shape
  from tensorflow.python.framework import test_util
  from tensorflow.python.module import module
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import variables
  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 5 for calling the ShardingPoliciesTest obj's underlying member method code with example usage: obj.test_MaxShardSizePolicy_Strings() without return types