code: def test_forward(self):
      dict_cfg = dict(
          type="Dictionary",
          dict_file="dicts/lower_english_digits.txt",
          with_start=True,
          with_end=True,
          same_start_end=True,
          with_padding=True,
          with_unknown=False,
      )
      max_seq_len = 40
      ce_loss = CEModuleLoss(dict_cfg)
      ce_loss.get_targets(self.gt)
      outputs = torch.rand(
          3, max_seq_len, ce_loss.dictionary.num_classes
      )
      losses = ce_loss(outputs, self.gt)
      self.assertIsInstance(losses, dict)
      self.assertIn("loss_ce", losses)
      self.assertEqual(losses["loss_ce"].size(1), max_seq_len)
  
      # test ignore_first_char
      ce_loss = CEModuleLoss(dict_cfg, ignore_first_char=True)
      ignore_first_char_losses = ce_loss(outputs, self.gt)
      self.assertEqual(
          ignore_first_char_losses["loss_ce"].shape,
          torch.Size([3, max_seq_len - 1]),
      )
  
      # test flatten
      ce_loss = CEModuleLoss(dict_cfg, flatten=True)
      flatten_losses = ce_loss(outputs, self.gt)
      self.assertEqual(
          flatten_losses["loss_ce"].shape, torch.Size([3 * max_seq_len])
      )
  
      self.assertTrue(
          torch.isclose(
              losses["loss_ce"].view(-1),
              flatten_losses["loss_ce"],
              atol=1e-6,
              rtol=0,
          ).all()
      )
  
file_path: mmocr/tests/test_models/test_textrecog/test_module_losses/test_ce_module_loss.py
imports: from unittest import TestCase
  import torch
  from mmengine.structures import LabelData
  from mmocr.models.textrecog.module_losses import CEModuleLoss
  from mmocr.structures import TextRecogDataSample
label_desc: Use image node_id 3 for calling the TestCEModuleLoss obj's underlying member method code with example usage: obj.test_forward() without return types