class_docstr: Implementation of loss module for CTC-loss based text recognition.
  
  Args:
      dictionary (dict or :obj:`Dictionary`): The config for `Dictionary` or
          the instance of `Dictionary`.
      letter_case (str): There are three options to alter the letter cases
          of gt texts:
          - unchanged: Do not change gt texts.
          - upper: Convert gt texts into uppercase characters.
          - lower: Convert gt texts into lowercase characters.
          Usually, it only works for English characters. Defaults to
          'unchanged'.
      flatten (bool): If True, use flattened targets, else padded targets.
      reduction (str): Specifies the reduction to apply to the output,
          should be one of the following: ('none', 'mean', 'sum').
      zero_infinity (bool): Whether to zero infinite losses and
          the associated gradients. Default: False.
          Infinite losses mainly occur when the inputs
          are too short to be aligned to the targets.
class_docstr_tok: ["Implementation","of","loss","module","for","CTC-loss","based","text","recognition",".","Args",":","dictionary","(","dict","or",":","obj",":","`","Dictionary","`",")",":","The","config","for","`","Dictionary","`","or","the","instance","of","`","Dictionary","`",".","letter_case","(","str",")",":","There","are","three","options","to","alter","the","letter","cases","of","gt","texts",":","-","unchanged",":","Do","not","change","gt","texts",".","-","upper",":","Convert","gt","texts","into","uppercase","characters",".","-","lower",":","Convert","gt","texts","into","lowercase","characters",".","Usually",",","it","only","works","for","English","characters",".","Defaults","to","'unchanged","'",".","flatten","(","bool",")",":","If","True",",","use","flattened","targets",",","else","padded","targets",".","reduction","(","str",")",":","Specifies","the","reduction","to","apply","to","the","output",",","should","be","one","of","the","following",":","(","'none","'",",","'mean","'",",","'sum","'",")",".","zero_infinity","(","bool",")",":","Whether","to","zero","infinite","losses","and","the","associated","gradients",".","Default",":","False",".","Infinite","losses","mainly","occur","when","the","inputs","are","too","short","to","be","aligned","to","the","targets","."]
code: def __init__(
      self,
      dictionary: Union[Dict, Dictionary],
      letter_case: str = "unchanged",
      flatten: bool = True,
      reduction: str = "mean",
      zero_infinity: bool = False,
      **kwargs,
  ) -> None:
      super().__init__(dictionary=dictionary, letter_case=letter_case)
      assert isinstance(flatten, bool)
      assert isinstance(reduction, str)
      assert isinstance(zero_infinity, bool)
  
      self.flatten = flatten
      self.ctc_loss = nn.CTCLoss(
          blank=self.dictionary.padding_idx,
          reduction=reduction,
          zero_infinity=zero_infinity,
      )
  
file_path: mmocr/mmocr/models/textrecog/module_losses/ctc_module_loss.py
imports: import math
  from typing import Dict, Sequence, Union
  import torch
  import torch.nn
  from mmocr.models.common.dictionary import Dictionary
  from mmocr.registry import MODELS
  from mmocr.structures import TextRecogDataSample
  from .base import BaseTextRecogModuleLoss
label_desc: Use image node_id 1 to create a new CTCModuleLoss object from inherited base classes: BaseTextRecogModuleLoss with example: obj = CTCModuleLoss(dictionary, letter_case, flatten, reduction, zero_infinity)