code: def wrap_tensor_or_dict_of_tensors_in_identity(
      tensor_or_dict_of_tensors: types.TensorTypeMaybeDict,
  ) -> types.TensorTypeMaybeDict:
      # pyformat: disable
      """Wrap the given Tensor / dict of Tensors in tf.identity.
  
      Args:
        tensor_or_dict_of_tensors: Tensor or dict of Tensors to wrap around.
  
      Workaround for TensorFlow issue #17568 (b/71769512).
  
      Returns:
        Tensor or dict of Tensors wrapped with tf.identity.
  
      Raises:
        ValueError: We could not wrap the given Tensor / dict of Tensors in
          tf.identity.
      """
      # pyformat: enable
  
      def _wrap_tensor_in_identity(
          tensor: types.TensorType,
      ) -> types.TensorType:
          if isinstance(tensor, (tf.Tensor, tf.RaggedTensor)):
              return tf.identity(tensor)
          elif isinstance(tensor, tf.SparseTensor):
              return tf.SparseTensor(
                  indices=tf.identity(tensor.indices),
                  values=tf.identity(tensor.values),
                  dense_shape=tf.identity(tensor.dense_shape),
              )
          else:
              raise ValueError(
                  "could not wrap Tensor %s in identity" % str(tensor)
              )
  
      if isinstance(tensor_or_dict_of_tensors, dict):
          result = {}
          for k, v in tensor_or_dict_of_tensors.items():
              # Dictionary elements should only be Tensors (and not dictionaries).
              result[k] = _wrap_tensor_in_identity(v)
          return result
      else:
          return _wrap_tensor_in_identity(tensor_or_dict_of_tensors)
  
file_path: model-analysis/tensorflow_model_analysis/eval_saved_model/util.py
imports: from typing import Any, Callable, List, Optional, Tuple
  import numpy
  import tensorflow
  from tensorflow import estimator
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.utils import util
  from tensorflow.core.example import example_pb2
label_desc: Use image node_id 3 for calling a global function with example usage: wrap_tensor_or_dict_of_tensors_in_identity(tensor_or_dict_of_tensors) and returns: result, _wrap_tensor_in_identity, tf, tf