code: def test_str2idx(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)
          self.assertEqual(dict_gen.str2idx("01234"), [0, 1, 2, 3, 4])
          with self.assertRaises(Exception):
              dict_gen.str2idx("H")
  
          dict_gen = Dictionary(dict_file=dict_file, with_unknown=True)
          self.assertListEqual(
              dict_gen.str2idx("H"), [dict_gen.unknown_idx]
          )
  
          dict_gen = Dictionary(
              dict_file=dict_file, with_unknown=True, unknown_token=None
          )
          self.assertListEqual(dict_gen.str2idx("H"), [])
  
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 4 for calling the TestDictionary obj's underlying member method code with example usage: obj.test_str2idx() without return types