code: def _ProcessGraphDefParam(graph_def):
      """Type-checks and possibly canonicalizes `graph_def`."""
      if not isinstance(graph_def, graph_pb2.GraphDef):
          # `graph_def` could be a dynamically-created message, so try a duck-typed
          # approach
          try:
              old_graph_def = graph_def
              graph_def = graph_pb2.GraphDef()
              graph_def.MergeFrom(old_graph_def)
          except TypeError:
              raise TypeError(
                  "Argument `graph_def` must be a GraphDef proto."
              )
      else:
          # If we're using the graph_def provided by the caller, modify graph_def
          # in-place to add attr defaults to the NodeDefs (this is visible to the
          # caller).
          # NOTE(skyewm): this is undocumented behavior that at least meta_graph.py
          # depends on. It might make sense to move this to meta_graph.py and have
          # import_graph_def not modify the graph_def argument (we'd have to make sure
          # this doesn't break anything else.)
          for node in graph_def.node:
              op_def = op_def_registry.get(node.op)
              if op_def is None:
                  # Assume unrecognized ops are functions for now. TF_ImportGraphDef will
                  # report an error if the op is actually missing.
                  continue
              _SetDefaultAttrValues(node, op_def)
  
      return graph_def
  
imports: import contextlib
  from tensorflow.core.framework import graph_pb2
  from tensorflow.python import tf2
  from tensorflow.python.client import pywrap_tf_session
  from tensorflow.python.framework import c_api_util
  from tensorflow.python.framework import device
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import function
  from tensorflow.python.framework import op_def_registry
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import control_flow_util
  from tensorflow.python.util import compat
  from tensorflow.python.util.deprecation import deprecated_args
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 4 for calling a global function with example usage: _ProcessGraphDefParam(graph_def) and returns: graph_def