code: def get_reachable_from_inputs(inputs, targets=None):
      """Returns the set of tensors/ops reachable from `inputs`.
  
      Stops if all targets have been found (target is optional).
  
      Only valid in Symbolic mode, not Eager mode.
  
      Args:
        inputs: List of tensors.
        targets: List of tensors.
  
      Returns:
        A set of tensors reachable from the inputs (includes the inputs themselves).
      """
      inputs = nest.flatten(inputs, expand_composites=True)
      reachable = object_identity.ObjectIdentitySet(inputs)
      if targets:
          remaining_targets = object_identity.ObjectIdentitySet(
              nest.flatten(targets)
          )
      queue = collections.deque(inputs)
  
      while queue:
          x = queue.pop()
          if isinstance(x, tuple(_user_convertible_tensor_types)):
              # Can't find consumers of user-specific types.
              continue
  
          if isinstance(x, ops.Operation):
              outputs = x.outputs[:] or []
              outputs += (
                  x._control_outputs
              )  # pylint: disable=protected-access
          elif isinstance(x, variables.Variable):
              try:
                  outputs = [x.op]
              except AttributeError:
                  # Variables can be created in an Eager context.
                  outputs = []
          elif tensor_util.is_tf_type(x):
              outputs = x.consumers()
          else:
              raise TypeError(
                  "Expected Operation, Variable, or Tensor, got "
                  + str(x)
              )
  
          for y in outputs:
              if y not in reachable:
                  reachable.add(y)
                  if targets:
                      remaining_targets.discard(y)
                  queue.appendleft(y)
  
          if targets and not remaining_targets:
              return reachable
  
      return reachable
  
imports: import collections
  import copy
  import numpy
  from tensorflow.python.data.experimental.ops import cardinality
  from tensorflow.python.distribute.coordinator import cluster_coordinator
  from tensorflow.python.eager import context
  from tensorflow.python.framework import composite_tensor
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.framework import type_spec
  from tensorflow.python.keras import backend
  from tensorflow.python.keras.engine import keras_tensor
  from tensorflow.python.keras.utils import object_identity
  from tensorflow.python.keras.utils import tf_contextlib
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow.python.ops.ragged import ragged_tensor_value
  from tensorflow.python.util import nest
label_desc: Use image node_id 2 for calling a global function with example usage: get_reachable_from_inputs(inputs, targets) and returns: reachable, reachable