class_docstr: CTC module.
  
  Args:
      odim: dimension of outputs
      encoder_output_size: number of encoder projection units
      dropout_rate: dropout rate (0.0 ~ 1.0)
      ctc_type: builtin or gtnctc
      reduce: reduce the CTC loss into a scalar
      ignore_nan_grad: Same as zero_infinity (keeping for backward compatiblity)
      zero_infinity:  Whether to zero infinite losses and the associated gradients.
code: def __init__(
      self,
      odim: int,
      encoder_output_size: int,
      dropout_rate: float = 0.0,
      ctc_type: str = "builtin",
      reduce: bool = True,
      ignore_nan_grad: bool = None,
      zero_infinity: bool = True,
      brctc_risk_strategy: str = "exp",
      brctc_group_strategy: str = "end",
      brctc_risk_factor: float = 0.0,
  ):
      assert check_argument_types()
      super().__init__()
      eprojs = encoder_output_size
      self.dropout_rate = dropout_rate
      self.ctc_lo = torch.nn.Linear(eprojs, odim)
      self.ctc_type = ctc_type
      if ignore_nan_grad is not None:
          zero_infinity = ignore_nan_grad
  
      if self.ctc_type == "builtin":
          self.ctc_loss = torch.nn.CTCLoss(
              reduction="none", zero_infinity=zero_infinity
          )
      elif self.ctc_type == "builtin2":
          self.ignore_nan_grad = True
          logging.warning("builtin2")
          self.ctc_loss = torch.nn.CTCLoss(reduction="none")
  
      elif self.ctc_type == "gtnctc":
          from espnet.nets.pytorch_backend.gtn_ctc import (
              GTNCTCLossFunction,
          )
  
          self.ctc_loss = GTNCTCLossFunction.apply
  
      elif self.ctc_type == "brctc":
          try:
              import k2
          except ImportError:
              raise ImportError(
                  "You should install K2 to use Bayes Risk CTC"
              )
  
          from espnet2.asr.bayes_risk_ctc import BayesRiskCTC
  
          self.ctc_loss = BayesRiskCTC(
              brctc_risk_strategy,
              brctc_group_strategy,
              brctc_risk_factor,
          )
  
      else:
          raise ValueError(
              f'ctc_type must be "builtin" or "gtnctc": {self.ctc_type}'
          )
  
      self.reduce = reduce
  
file_path: espnet/espnet2/asr/ctc.py
imports: import logging
  import torch
  import torch.nn.functional
  from typeguard import check_argument_types
label_desc: Use image node_id 1 to create a new CTC object from inherited base classes: torch.nn with example: obj = CTC(odim, encoder_output_size, dropout_rate, ctc_type, reduce, ignore_nan_grad, zero_infinity, brctc_risk_strategy, brctc_group_strategy, brctc_risk_factor)