class_docstr: A class that represents a collection/database of rewrites.
  
  These databases are used to logically organize collections of rewrites
  (i.e. `GraphRewriter`\s and `NodeRewriter`).
class_docstr_tok: ["A","class","that","represents","a","collection\/database","of","rewrites",".","These","databases","are","used","to","logically","organize","collections","of","rewrites","(","i.e",".","`","GraphRewriter","`","\\s","and","`","NodeRewriter","`",")","."]
docstr: Register a new rewriter to the database.
  
  Parameters
  ----------
  name:
      Name of the rewriter.
  rewriter:
      The rewriter to register.
  tags:
      Tag name that allows one to select the rewrite using a
      `RewriteDatabaseQuery`.
  use_db_name_as_tag:
      Add the database's name as a tag, so that its name can be used in a
      query.
      By default, all rewrites registered to an `EquilibriumDB` are
      selected when the ``"EquilibriumDB"`` name is used as a tag. We do
      not want this behavior for some rewrites like
      ``local_remove_all_assert``. Setting `use_db_name_as_tag` to
      ``False`` removes that behavior. This means that only the rewrite's name
      and/or its tags will enable it.
code: def register(
      self,
      name: str,
      rewriter: Union["RewriteDatabase", RewritesType],
      *tags: str,
      use_db_name_as_tag=True,
  ):
      """Register a new rewriter to the database.
  
      Parameters
      ----------
      name:
          Name of the rewriter.
      rewriter:
          The rewriter to register.
      tags:
          Tag name that allows one to select the rewrite using a
          `RewriteDatabaseQuery`.
      use_db_name_as_tag:
          Add the database's name as a tag, so that its name can be used in a
          query.
          By default, all rewrites registered to an `EquilibriumDB` are
          selected when the ``"EquilibriumDB"`` name is used as a tag. We do
          not want this behavior for some rewrites like
          ``local_remove_all_assert``. Setting `use_db_name_as_tag` to
          ``False`` removes that behavior. This means that only the rewrite's name
          and/or its tags will enable it.
  
      """
      if not isinstance(
          rewriter,
          (
              RewriteDatabase,
              pytensor_rewriting.GraphRewriter,
              pytensor_rewriting.NodeRewriter,
          ),
      ):
          raise TypeError(f"{rewriter} is not a valid rewrite type.")
  
      if name in self.__db__:
          raise ValueError(
              f"The tag '{name}' is already present in the database."
          )
  
      if use_db_name_as_tag:
          if self.name is not None:
              tags = tags + (self.name,)
  
      rewriter.name = name
      # This restriction is there because in many place we suppose that
      # something in the RewriteDatabase is there only once.
      if rewriter.name in self.__db__:
          raise ValueError(
              f"Tried to register {rewriter.name} again under the new name {name}. "
              "The same rewrite cannot be registered multiple times in"
              " an `RewriteDatabase`; use `ProxyDB` instead."
          )
      self.__db__[name] = OrderedSet([rewriter])
      self._names.add(name)
      self.__db__[rewriter.__class__.__name__].add(rewriter)
      self.add_tags(name, *tags)
  
imports: import copy
  import math
  import sys
  from collections.abc import Iterable, Sequence
  from functools import cmp_to_key
  from io import StringIO
  from typing import Optional, Union
  from pytensor.configdefaults import config
  from pytensor.graph.rewriting import basic
  from pytensor.misc.ordered_set import OrderedSet
  from pytensor.utils import DefaultOrderedDict
label_desc: Use image node_id 2 for calling the RewriteDatabase obj's underlying member method code with example usage: obj.register(name, rewriter) without return types