code: def get_function_def(fname, graph):
      """Gets a function definition with `fname` in the current context."""
      if context.executing_eagerly():
          # Eager mode: use eager context as the single source of truth.
          if context.context().has_function(fname):
              return context.context().get_function_def(fname)
      else:
          # Graph mode: use outer graphs as the single source of truth.
          while graph is not None:
              if graph._is_function(
                  fname
              ):  # pylint: disable=protected-access
                  return graph._get_function(
                      fname
                  ).cached_definition  # pylint: disable=protected-access
              graph = getattr(graph, "outer_graph", None)
  
file_path: tensorflow-upstream/tensorflow/python/framework/function_def_to_graph.py
imports: import itertools
  from tensorflow.core.framework import function_pb2
  from tensorflow.core.framework import graph_pb2
  from tensorflow.core.framework import tensor_shape_pb2
  from tensorflow.core.framework import types_pb2
  from tensorflow.core.framework import versions_pb2
  from tensorflow.python.eager import context
  from tensorflow.python.framework import cpp_shape_inference_pb2
  from tensorflow.python.framework import importer
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import versions
  from tensorflow.python.framework.func_graph import FuncGraph
  from tensorflow.python.ops import resource_variable_ops
label_desc: Use image node_id 3 for calling a global function with example usage: get_function_def(fname, graph) and returns: context, graph