code: def register_rule(cls, rule_type: Type[OptimizationRule]):
      if not hasattr(cls, "_rule_types"):
          cls._rule_types = []
      cls._rule_types.append(rule_type)
  
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 for calling the Optimizer obj's underlying member method code with example usage: obj.register_rule(cls, rule_type) without return types