def _get_parents(self, tensor_or_op):
    """Get the parents of the given `tensor_or_op`."""
    if tf_utils.hashable_tensor_or_op(tensor_or_op) in self._source_info_dict:
      return []

    # func_graph_name is not None only if the graph is a FuncGraph.
    func_graph_name = getattr(self._graph, 'name', None)
    if isinstance(tensor_or_op, tf.Operation):
      if tensor_or_op.type in _INITIALIZABLE_TABLE_OP_TYPES:
        raise _UnexpectedTableError(tensor_or_op, func_graph_name)
      if tensor_or_op.type == 'Placeholder':
        # If we're not in the context of a tf.function, this is an error.
        if func_graph_name is None:
          raise _UnexpectedPlaceholderError(tensor_or_op, func_graph_name)
        # If we're in the context of a tf.function and this op is part of its
        # inputs, that's expected.
        if tensor_or_op not in [x.op for x in self._graph.inputs]:
          raise _UnexpectedPlaceholderError(tensor_or_op, func_graph_name)
      parents = list(
          itertools.chain(tensor_or_op.inputs, tensor_or_op.control_inputs))
    elif isinstance(tensor_or_op, tf.Tensor):
      parents = [tensor_or_op.op]
    else:
      raise TypeError('Expected Tensor or Operation, got {} of type {}'.format(
          tensor_or_op, type(tensor_or_op)))
    return parents
Get the parents of the given `tensor_or_op`.
tensorflow_transform/graph_tools.py