code: def maybe_get_remote_value(val):
      """Gets the value of `val` if it is a `RemoteValue`."""
      if isinstance(val, remote_value.RemoteValue):
          error = val._get_error()  # pylint: disable=protected-access
          if error:
              raise AssertionError(
                  "RemoteValue doesn't have a value because it has error %r:%s"
                  % (error, error)
              )
          elif (
              val._status is not remote_value.RemoteValueStatus.READY
          ):  # pylint: disable=protected-access
              raise AssertionError(
                  "The input RemoteValue has not been executed."
              )
          else:
              return (
                  val._get_values()
              )  # pylint: disable=protected-access
      else:
          return val
  
file_path: tensorflow-upstream/tensorflow/python/distribute/coordinator/coordinator_context.py
imports: import contextlib
  import threading
  from tensorflow.core.framework import attr_value_pb2
  from tensorflow.python.distribute.coordinator import remote_value
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.util import compat
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 3 for calling a global function with example usage: maybe_get_remote_value(val) and returns: val, val