class_docstr: Check if variables can be expressed without using variables in invalid.
  
  Parameters
  ----------
  valid_equivalent
      Provides a dictionary mapping some invalid variables to valid ones that
      can be used instead.
class_docstr_tok: ["Check","if","variables","can","be","expressed","without","using","variables","in","invalid",".","Parameters","--","--","--","--","--","valid_equivalent","Provides","a","dictionary","mapping","some","invalid","variables","to","valid","ones","that","can","be","used","instead","."]
code: def __init__(self, valid=None, invalid=None, valid_equivalent=None):
      if valid is None:
          valid = []
      if invalid is None:
          invalid = []
      if valid_equivalent is None:
          valid_equivalent = OrderedDict()
  
      # Nodes that are valid to have in the graph computing outputs
      self.valid = set(valid)
  
      # Nodes that are NOT valid to have in the graph computing outputs
      self.invalid = set(invalid)
  
      # Mapping from invalid variables to equivalent valid ones.
      self.valid_equivalent = valid_equivalent.copy()
      self.valid.update(list(valid_equivalent.values()))
      self.invalid.update(list(valid_equivalent.keys()))
  
imports: import copy
  import dataclasses
  import logging
  from collections import OrderedDict, namedtuple
  from collections.abc import Sequence
  from itertools import chain
  from typing import TYPE_CHECKING, Callable, Optional, Union
  from typing import cast
  import numpy
  from pytensor import scalar
  from pytensor import tensor
  from pytensor.compile.profiling import ProfileStats
  from pytensor.configdefaults import config
  from pytensor.graph.basic import Constant, Variable, equal_computations, graph_inputs
  from pytensor.graph.op import get_test_value
  from pytensor.graph.replace import clone_replace
  from pytensor.graph.type import HasDataType
  from pytensor.graph.utils import TestValueError
  from pytensor.tensor.basic import AllocEmpty, cast
  from pytensor.tensor.subtensor import set_subtensor
  from pytensor.tensor.variable import TensorConstant
label_desc: Use image node_id 1 to create a new Validator object  with example: obj = Validator(valid, invalid, valid_equivalent)