code: def to_replacement(self) -> Replacement:
      if self.type == RuleTypes.RAW:
          return Replacement(*self.rule, regex=False)
      elif self.type == RuleTypes.REGEX:
          return Replacement(*self.rule, regex=True)
      else:
          raise NotImplementedError(f"Unknown RuleType {self.type}")
  
imports: import json
  import logging
  import re
  from dataclasses import dataclass, field
  from pathlib import Path
  from typing import List, Type, Optional, Dict, Tuple, Union, Callable
  from dataclasses_json import dataclass_json
  from paiargparse import pai_dataclass, pai_meta
  from tfaip.data.pipeline.processor.dataprocessor import DataProcessorParams
  from tfaip.util.enum import StrEnum
  from calamari_ocr import calamari_ocr_dir
  from calamari_ocr.ocr.dataset.textprocessors import TextProcessor
label_desc: Use image node_id 1 for calling the Rule obj's underlying member method code with example usage: obj.to_replacement() and returns: Replacement, Replacement