def METHOD_NAME(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_recog_loss = BaseTextRecogModuleLoss(dict_cfg)
    self.assertIsInstance(base_recog_loss.dictionary, Dictionary)
    # test case mode
    with self.assertRaises(AssertionError):
        base_recog_loss = BaseTextRecogModuleLoss(
            dict_cfg, letter_case='no')
    # test invalid pad_with
    with self.assertRaises(AssertionError):
        base_recog_loss = BaseTextRecogModuleLoss(
            dict_cfg, pad_with='test')
    # test invalid combination of dictionary and pad_with
    dict_cfg = dict(type='Dictionary', dict_file=dict_file, with_end=False)
    for pad_with in ['end', 'padding']:
        with self.assertRaisesRegex(
                ValueError, f'pad_with="{pad_with}", but'
                f' dictionary.{pad_with}_idx is None'):
            base_recog_loss = BaseTextRecogModuleLoss(
                dict_cfg, pad_with=pad_with)
    with self.assertRaisesRegex(
            ValueError, 'pad_with="auto", but'
            ' dictionary.end_idx and dictionary.padding_idx are both'
            ' None'):
        base_recog_loss = BaseTextRecogModuleLoss(
            dict_cfg, pad_with='auto')
    # 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_recog_loss = BaseTextRecogModuleLoss(dict_cfg)
    tmp_dir.cleanup()