code: def _get_shardable_tensors_by_task(self, root):
      serialized_tensors, _, _, _ = checkpoint.TrackableSaver(
          graph_view.ObjectGraphView(root)
      )._gather_serialized_tensors(None)
  
      shardable_tensors_by_task = {}
      for obj, tensor_dict in serialized_tensors.items():
          # Divide tensor_dict by device.
          for checkpoint_key, tensor_slice_dict in tensor_dict.items():
              if not isinstance(tensor_slice_dict, dict):
                  # Make sure that maybe_tensor is structured as {slice_spec -> tensor}.
                  tensor_slice_dict = {"": tensor_slice_dict}
              for (
                  slice_spec,
                  tensor_save_spec,
              ) in tensor_slice_dict.items():
                  if not isinstance(
                      tensor_save_spec, saveable_object.SaveSpec
                  ):
                      tensor_save_spec = saveable_object.SaveSpec(
                          tensor=tensor_save_spec,
                          slice_spec=slice_spec,
                          name=checkpoint_key,
                          dtype=tensor_save_spec.dtype,
                          device=tensor_save_spec.device,
                      )
                  save_spec_tensor = tensor_save_spec.tensor
                  device = (
                      device_lib.DeviceSpec.from_string(
                          tensor_save_spec.device
                      )
                      if isinstance(tensor_save_spec.device, str)
                      else tensor_save_spec.device
                  )
                  task = device_lib.DeviceSpec.from_string(
                      saveable_object_util.set_cpu0(device.to_string())
                  )
                  shardable_tensors_by_task.setdefault(task, []).append(
                      sharding_util.ShardableTensor(
                          _tensor_save_spec=tensor_save_spec,
                          tensor=save_spec_tensor,
                          dtype=tensor_save_spec.dtype,
                          device=device,
                          name=tensor_save_spec.name,
                          shape=save_spec_tensor.shape,
                          slice_spec=slice_spec,
                          checkpoint_key=checkpoint_key,
                          trackable=obj,
                      )
                  )
      return shardable_tensors_by_task.values()
  
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 1 for calling the ShardingPoliciesTest obj's underlying member method code with example usage: obj._get_shardable_tensors_by_task(root) and returns: shardable_tensors_by_task