code: def test_char2idx(self):
      with tempfile.TemporaryDirectory() as tmp_dir:
          # create dummy data
          dict_file = osp.join(tmp_dir, "fake_chars.txt")
          create_dummy_dict_file(dict_file)
          dict_gen = Dictionary(dict_file=dict_file, with_unknown=False)
          self.assertEqual(dict_gen.char2idx("0"), 0)
  
          dict_gen = Dictionary(dict_file=dict_file, with_unknown=True)
          self.assertEqual(dict_gen.char2idx("H"), dict_gen.unknown_idx)
  
          dict_gen = Dictionary(
              dict_file=dict_file, with_unknown=True, unknown_token=None
          )
          self.assertEqual(dict_gen.char2idx("H"), None)
  
          # Test strict
          dict_gen = Dictionary(dict_file=dict_file, with_unknown=False)
          with self.assertRaises(Exception):
              dict_gen.char2idx("H", strict=True)
          self.assertEqual(dict_gen.char2idx("H", strict=False), None)
  
file_path: mmocr/tests/test_models/test_textrecog/test_dictionary/test_dictionary.py
imports: import os.path
  import tempfile
  from unittest import TestCase
  from mmocr.models.common import Dictionary
  from mmocr.testing import create_dummy_dict_file
label_desc: Use image node_id 3 for calling the TestDictionary obj's underlying member method code with example usage: obj.test_char2idx() without return types