code: def __init__(
      self,
      graph: EntityGraph,
      records: OptimizationRecords,
      optimizer_cls: Type["Optimizer"],
  ):
      self._graph = graph
      self._records = records
      self._optimizer_cls = optimizer_cls
      self._cached_rule = functools.lru_cache(maxsize=None)(
          lambda _rule_type: _rule_type(
              self._graph, self._records, self._optimizer_cls
          )
      )
  
imports: import functools
  import weakref
  from abc import ABC, abstractmethod
  from collections import defaultdict
  from dataclasses import dataclass
  from enum import Enum
  from typing import Dict, List, Optional, Type, Set
  from ...core import OperandType, EntityType, enter_mode
  from ...core.graph import EntityGraph
  from ...utils import implements
label_desc: Use image node_id 1 to create a new OptimizationRule object from inherited base classes: ABC with example: obj = OptimizationRule(graph, records, optimizer_cls)