code: def test_init(self):
      tmp_dir = tempfile.TemporaryDirectory()
      dict_file = osp.join(tmp_dir.name, "fake_chars.txt")
      create_dummy_dict_file(dict_file)
      # test diction cfg
      dict_cfg = dict(
          type="Dictionary",
          dict_file=dict_file,
          with_start=True,
          with_end=True,
          same_start_end=False,
          with_padding=True,
          with_unknown=True,
      )
      base_postprocessor = BaseTextRecogPostprocessor(dict_cfg)
      self.assertIsInstance(base_postprocessor.dictionary, Dictionary)
      self.assertListEqual(
          base_postprocessor.ignore_indexes,
          [base_postprocessor.dictionary.padding_idx],
      )
  
      base_postprocessor = BaseTextRecogPostprocessor(
          dict_cfg, ignore_chars=["1", "2", "3"]
      )
  
      self.assertListEqual(base_postprocessor.ignore_indexes, [1, 2, 3])
  
      # test ignore_chars
      with self.assertRaisesRegex(
          TypeError, "ignore_chars must be list of str"
      ):
          base_postprocessor = BaseTextRecogPostprocessor(
              dict_cfg, ignore_chars=[1, 2, 3]
          )
      with self.assertWarnsRegex(
          Warning, "M does not exist in the dictionary"
      ):
          base_postprocessor = BaseTextRecogPostprocessor(
              dict_cfg, ignore_chars=["M"]
          )
  
      base_postprocessor = BaseTextRecogPostprocessor(
          dict_cfg, ignore_chars=["1", "2", "3"]
      )
      # test dictionary is invalid type
      dict_cfg = ["tmp"]
      with self.assertRaisesRegex(
          TypeError,
          (
              "The type of dictionary should be `Dictionary`"
              " or dict, "
              f"but got {type(dict_cfg)}"
          ),
      ):
          base_postprocessor = BaseTextRecogPostprocessor(dict_cfg)
      # test diction cfg with with_unknown=False
      dict_cfg = dict(
          type="Dictionary",
          dict_file=dict_file,
          with_start=True,
          with_end=True,
          same_start_end=False,
          with_padding=True,
          with_unknown=False,
      )
      base_postprocessor = BaseTextRecogPostprocessor(
          dict_cfg, ignore_chars=["1", "2", "3"]
      )
  
      self.assertListEqual(base_postprocessor.ignore_indexes, [1, 2, 3])
  
      # test ignore_chars
      with self.assertRaisesRegex(
          TypeError, "ignore_chars must be list of str"
      ):
          base_postprocessor = BaseTextRecogPostprocessor(
              dict_cfg, ignore_chars=[1, 2, 3]
          )
  
      with self.assertWarnsRegex(
          Warning, "M does not exist in the dictionary"
      ):
          base_postprocessor = BaseTextRecogPostprocessor(
              dict_cfg, ignore_chars=["M"]
          )
  
      with self.assertWarnsRegex(
          Warning, "M does not exist in the dictionary"
      ):
          base_postprocessor = BaseTextRecogPostprocessor(
              dict(
                  type="Dictionary",
                  dict_file=dict_file,
                  with_unknown=True,
                  unknown_token=None,
              ),
              ignore_chars=["M"],
          )
  
      with self.assertWarnsRegex(
          Warning, "M does not exist in the dictionary"
      ):
          base_postprocessor = BaseTextRecogPostprocessor(
              dict(
                  type="Dictionary",
                  dict_file=dict_file,
                  with_unknown=True,
              ),
              ignore_chars=["M"],
          )
  
      with self.assertWarnsRegex(
          Warning, "unknown does not exist in the dictionary"
      ):
          base_postprocessor = BaseTextRecogPostprocessor(
              dict(
                  type="Dictionary",
                  dict_file=dict_file,
                  with_unknown=False,
              ),
              ignore_chars=["unknown"],
          )
  
      base_postprocessor = BaseTextRecogPostprocessor(
          dict_cfg, ignore_chars=["1", "2", "3"]
      )
      # test dictionary is invalid type
      dict_cfg = ["tmp"]
      with self.assertRaisesRegex(
          TypeError,
          (
              "The type of dictionary should be `Dictionary`"
              " or dict, "
              f"but got {type(dict_cfg)}"
          ),
      ):
          base_postprocessor = BaseTextRecogPostprocessor(dict_cfg)
  
      tmp_dir.cleanup()
  
file_path: mmocr/tests/test_models/test_textrecog/test_postprocessors/test_base_textrecog_postprocessor.py
imports: import os.path
  import tempfile
  from unittest import TestCase, mock
  import torch
  from mmocr.models.common.dictionary import Dictionary
  from mmocr.models.textrecog.postprocessors import BaseTextRecogPostprocessor
  from mmocr.structures import TextRecogDataSample
  from mmocr.testing import create_dummy_dict_file
label_desc: Use image node_id 1 for calling the TestBaseTextRecogPostprocessor obj's underlying member method code with example usage: obj.test_init() without return types