code: def test_get_targets(self):
      tmp_dir = tempfile.TemporaryDirectory()
      # create dummy data
      dict_file = osp.join(tmp_dir.name, "fake_chars.txt")
      create_dummy_dict_file(dict_file, list("helowrd"))
  
      dictionary = Dictionary(dict_file=dict_file, with_padding=True)
      loss = CTCModuleLoss(dictionary=dictionary, letter_case="lower")
      # test encode str to tensor
      datasample1 = TextRecogDataSample()
      gt_text1 = LabelData(item="hell")
      datasample1.gt_text = gt_text1
      datasample2 = datasample1.clone()
      gt_text2 = LabelData(item="owrd")
      datasample2.gt_text = gt_text2
  
      data_samples = [datasample1, datasample2]
      expect_tensor1 = torch.IntTensor([0, 1, 2, 2])
      expect_tensor2 = torch.IntTensor([3, 4, 5, 6])
  
      data_samples = loss.get_targets(data_samples)
      self.assertTrue(
          torch.allclose(
              data_samples[0].gt_text.indexes, expect_tensor1
          )
      )
      self.assertTrue(
          torch.allclose(
              data_samples[1].gt_text.indexes, expect_tensor2
          )
      )
      tmp_dir.cleanup()
  
file_path: mmocr/tests/test_models/test_textrecog/test_module_losses/test_ctc_module_loss.py
imports: import os.path
  import tempfile
  from unittest import TestCase
  import torch
  from mmengine.structures import LabelData
  from mmocr.models.common.dictionary import Dictionary
  from mmocr.models.textrecog.module_losses import CTCModuleLoss
  from mmocr.structures import TextRecogDataSample
  from mmocr.testing import create_dummy_dict_file
label_desc: Use image node_id 2 for calling the TestCTCModuleLoss obj's underlying member method code with example usage: obj.test_get_targets() without return types