code: def build_graph_fn(
      mlmd_handle: metadata.Metadata,
      input_graph: pipeline_pb2.InputGraph,
  ) -> Tuple[_GraphFn, List[str]]:
      """Build a functional interface for the `input_graph`.
  
      Returned function can be called with a dict of input artifacts that are
      specified from the `InputNode` of the `InputGraph`.
  
      Example:
        inputs = previously_resolved_inputs()
        graph_fn, input_keys = build_graph_fn(mlmd_handle, input_graph)
        # input_keys == ['x', 'y']
        z = graph_fn({'x': inputs['x'], 'y': inputs['y']})
  
      Args:
        mlmd_handle: A `Metadata` instance.
        input_graph: An `pipeline_pb2.InputGraph` proto.
  
      Returns:
        Tuple of (graph_fn, graph_fn_inputs).
        graph_fn_inputs is a list of input keys, where all input keys must exist in
        the input argument dict to the graph_fn.
      """
      if input_graph.result_node not in input_graph.nodes:
          raise exceptions.FailedPreconditionError(
              f"result_node {input_graph.result_node} does not exist in input_graph. "
              f"Valid node ids: {list(input_graph.nodes.keys())}"
          )
  
      context = _Context(
          mlmd_handle=mlmd_handle, input_graph=input_graph
      )
  
      input_key_to_node_id = {}
      for node_id in input_graph.nodes:
          node_def = input_graph.nodes[node_id]
          if node_def.WhichOneof("kind") == "input_node":
              input_key_to_node_id[
                  node_def.input_node.input_key
              ] = node_id
  
      def initial_graph_fn(data: Mapping[str, _Data]) -> _Data:
          return data[input_graph.result_node]
  
      graph_fn = initial_graph_fn
      for node_id in reversed(
          list(_topologically_sorted_node_ids(input_graph))
      ):
          graph_fn = _reduce_graph_fn(context, node_id, graph_fn)
  
      def facade_fn(inputs: Mapping[str, _Data]) -> _Data:
          return graph_fn(
              {
                  node_id: inputs[input_key]
                  for input_key, node_id in input_key_to_node_id.items()
              }
          )
  
      return facade_fn, list(input_key_to_node_id.keys())
  
imports: import collections
  import dataclasses
  import functools
  from typing import Union, Sequence, Mapping, Tuple, List, Iterable, Callable
  from tfx import types
  from tfx.dsl.components.common import resolver
  from tfx.dsl.input_resolution import resolver_op
  from tfx.dsl.input_resolution.ops import ops
  from tfx.orchestration import data_types_utils
  from tfx.orchestration import metadata
  from tfx.orchestration.portable.input_resolution import exceptions
  from tfx.proto.orchestration import pipeline_pb2
  from tfx.utils import topsort
  from tfx.utils import typing_utils
label_desc: Use image node_id 6 for calling a global function with example usage: build_graph_fn(mlmd_handle, input_graph) and returns: facade_fn,  list, data, graph_fn