code: def get_dependent_inputs(graph, input_tensors, output_tensors):
      """Returns tensors in input_tensors that (transitively) produce output_tensors.
  
      Args:
        graph: A `tf.Graph`. It could be the (intermediate) output tf graph in any
          transform phase (including phase 0 where no tensor replacement has yet
          happened).
        input_tensors: A dict of logical name to `tf.Tensor`, `tf.SparseTensor`, or
          `tf.RaggedTensor`. Logical name doesn't have any implications in this
          method and can be anything. In some cases it is the feature name
          corresponding to the input tensor.
        output_tensors: A dict of logical name to `tf.Tensor`, `tf.SparseTensor`, or
          `tf.RaggedTensor`, or a list of `tf.Tensor`, `tf.SparseTensor`, or
          `tf.RaggedTensor`.
  
      Returns:
        A dict of logical name to `tf.Tensor`, `tf.SparseTensor`, or
        `tf.RaggedTensor` that are filtered from input_tensors (transitively)
        producing output_tensors
      """
      if isinstance(output_tensors, list):
          output_container = output_tensors
      else:
          output_container = output_tensors.values()
  
      # Since this method may be called before all tensor replacements are ready, to
      # fulfill the precondition of InitializableGraphAnalyzer, we fake the
      # readiness of tensor replacements. Note that the readiness of replacement
      # tensors doesn't affect the correctness of dependencies tracing.
      tensor_sinks = graph.get_collection(
          analyzer_nodes.TENSOR_REPLACEMENTS
      )
      sink_tensors_ready = [
          (sink.tensor, False) for sink in tensor_sinks
      ]
      graph_analyzer = _QuietInitializableGraphAnalyzer(
          graph, input_tensors, sink_tensors_ready
      )
      dependent_inputs = {}
      for output_tensor in output_container:
          dependent_inputs.update(
              graph_analyzer.get_dependent_inputs(output_tensor)
          )
      return {
          name: tensor
          for name, tensor in input_tensors.items()
          if name in dependent_inputs
      }
  
imports: import collections
  import copy
  import hashlib
  import itertools
  from typing import Iterable, List, Mapping, Optional, Set, Union
  import uuid
  from absl import logging
  import tensorflow
  from tensorflow_transform import analyzer_nodes
  from tensorflow_transform import common_types
  from tensorflow_transform import nodes
  from tensorflow_transform import tf_utils
  from tfx_bsl.types import tfx_namedtuple
  from tensorflow.python.framework import composite_tensor
  from tensorflow.python.framework import func_graph
  from tensorflow.python.framework import function_def_to_graph
  from tensorflow.python.util import object_identity
label_desc: Use image node_id 6 for calling a global function with example usage: get_dependent_inputs(graph, input_tensors, output_tensors) and returns: unknown