code: def _single_shard_save(
      file_prefix: tensor_lib.Tensor,
      shard: sharding_util.TensorSliceDict,
      task: device_lib.DeviceSpec,
      options: "checkpoint_options.CheckpointOptions | None" = None,
  ) -> ops.Operation:
      """Save the saveable objects to a checkpoint with `file_prefix`.
  
      Args:
        file_prefix: A string or scalar string Tensor containing the prefix to
          save under.
        shard: Dict containing tensors. {checkpoint key: {slice_spec: tensor} }
        task: The device spec task of the tensors in the shard.
        options: Optional `CheckpointOptions` object.
  
      Returns:
        An `Operation`, or None when executing eagerly.
      """
      options = options or checkpoint_options.CheckpointOptions()
  
      tensor_names = []
      tensors = []
      slice_specs = []
      for checkpoint_key, tensor_slices in shard.items():
          for slice_spec, tensor in tensor_slices.items():
              # A tensor value of `None` indicates that this SaveableObject gets
              # recorded in the object graph, but that no value is saved in the
              # checkpoint.
              if tensor is not None:
                  # See `MultiDeviceSaver._get_shards_by_task` for an explanation on the
                  # wrapped properties.
                  name = (
                      tensor._wrapped_name  # pylint: disable=protected-access
                      if hasattr(tensor, "_wrapped_name")
                      else checkpoint_key
                  )
                  spec = (
                      tensor._wrapped_slice_spec  # pylint: disable=protected-access
                      if hasattr(tensor, "_wrapped_slice_spec")
                      else slice_spec
                  )
  
                  tensor_names.append(name)
                  tensors.append(tensor)
                  slice_specs.append(spec)
  
      save_device = options.experimental_io_device or (
          len(tensors) and task
      )
      with ops.device(save_device or "CPU:0"):
          return io_ops.save_v2(
              file_prefix, tensor_names, slice_specs, tensors
          )
  
imports: import dataclasses
  from typing import Callable, Mapping, MutableMapping, MutableSequence, Sequence
  from tensorflow.core.protobuf import saver_pb2
  from tensorflow.python.checkpoint import checkpoint_options
  from tensorflow.python.checkpoint.sharding import sharding_policies
  from tensorflow.python.checkpoint.sharding import sharding_util
  from tensorflow.python.eager import context
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import constant_op
  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.framework import tensor_spec
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gen_io_ops
  from tensorflow.python.ops import io_ops
  from tensorflow.python.ops import string_ops
  from tensorflow.python.saved_model import registration
  from tensorflow.python.trackable import base
  from tensorflow.python.trackable import trackable_utils
  from tensorflow.python.training.saving import saveable_object
  from tensorflow.python.training.saving import saveable_object_util
  from tensorflow.python.types import core
  from tensorflow.python.util import nest
  from tensorflow.python.util import object_identity
label_desc: Use image node_id 1 for calling a global function with example usage: _single_shard_save(file_prefix, shard, task, options) and returns: io_ops