code: def _get_tensors_from_trackable(
      trackable_data: _TrackableData,
      call_with_mapped_captures: Union[Callable[..., Any], None],
      object_graph_proto: trackable_object_graph_pb2.TrackableObjectGraph,
  ) -> Dict[str, Any]:
      """Gets tensors to serialize from a Trackable."""
      trackable = trackable_data.object_to_save
      save_fn = (
          trackable._serialize_to_tensors
      )  # pylint: disable=protected-access
  
      if call_with_mapped_captures and isinstance(
          save_fn, core.ConcreteFunction
      ):
          ret_tensor_dict = call_with_mapped_captures(save_fn, [])
      else:
          ret_tensor_dict = save_fn()
  
      # Create checkpoint keys for each entry in the returned tensor dict, and
      # write each entry to the object proto.
      tensor_dict = {}
      for tensor_name, maybe_tensor in ret_tensor_dict.items():
          local_name = trackable_utils.escape_local_name(tensor_name)
          checkpoint_key = trackable_utils.checkpoint_key(
              trackable_data.object_name, local_name
          )
          tensor_dict[checkpoint_key] = maybe_tensor
  
          # TODO(b/261786493): Delete this when DCheckpoint is removed.
          if isinstance(maybe_tensor, saveable_object_lib.SaveSpec):
              maybe_tensor.name = checkpoint_key
              maybe_tensor.slice_spec = ""
  
          if object_graph_proto is not None:
              object_graph_proto.nodes[
                  trackable_data.node_id
              ].attributes.add(
                  name=local_name,
                  checkpoint_key=checkpoint_key,
                  full_name=util.get_full_name(trackable),
              )
  
      return tensor_dict
  
imports: import collections
  from typing import Any, Callable, List, Optional, Tuple, Mapping, Union, Dict
  from tensorflow.core.protobuf import trackable_object_graph_pb2
  from tensorflow.python.checkpoint import graph_view
  from tensorflow.python.checkpoint import save_util_v1
  from tensorflow.python.checkpoint import saveable_compat
  from tensorflow.python.checkpoint import util
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.saved_model import registration
  from tensorflow.python.trackable import base
  from tensorflow.python.trackable import python_state
  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 object_identity
label_desc: Use image node_id 6 for calling a global function with example usage: _get_tensors_from_trackable(trackable_data, call_with_mapped_captures, object_graph_proto) and returns: tensor_dict