class_docstr: CTC module
  
  :param int odim: dimension of outputs
  :param int eprojs: number of encoder projection units
  :param float dropout_rate: dropout rate (0.0 ~ 1.0)
  :param str ctc_type: builtin
  :param bool reduce: reduce the CTC loss into a scalar
code: def __init__(
      self, odim, eprojs, dropout_rate, ctc_type="builtin", reduce=True
  ):
      super().__init__()
      self.dropout_rate = dropout_rate
      self.loss = None
      self.ctc_lo = torch.nn.Linear(eprojs, odim)
      self.dropout = torch.nn.Dropout(dropout_rate)
      self.probs = None  # for visualization
  
      # In case of Pytorch >= 1.7.0, CTC will be always builtin
      self.ctc_type = (
          ctc_type if V(torch.__version__) < V("1.7.0") else "builtin"
      )
  
      if ctc_type != self.ctc_type:
          logging.warning(
              f"CTC was set to {self.ctc_type} due to PyTorch version."
          )
  
      if self.ctc_type == "builtin":
          reduction_type = "sum" if reduce else "none"
          self.ctc_loss = torch.nn.CTCLoss(
              reduction=reduction_type, zero_infinity=True
          )
      elif self.ctc_type == "cudnnctc":
          reduction_type = "sum" if reduce else "none"
          self.ctc_loss = torch.nn.CTCLoss(reduction=reduction_type)
      elif self.ctc_type == "gtnctc":
          from espnet.nets.pytorch_backend.gtn_ctc import (
              GTNCTCLossFunction,
          )
  
          self.ctc_loss = GTNCTCLossFunction.apply
      else:
          raise ValueError(
              'ctc_type must be "builtin" or "gtnctc": {}'.format(
                  self.ctc_type
              )
          )
  
      self.ignore_id = -1
      self.reduce = reduce
  
file_path: espnet/espnet/nets/pytorch_backend/ctc.py
imports: import logging
  import numpy
  import torch
  import torch.nn.functional
  from packaging.version import parse
  from espnet.nets.pytorch_backend.nets_utils import to_device
label_desc: Use image node_id 1 to create a new CTC object from inherited base classes: torch.nn with example: obj = CTC(odim, eprojs, dropout_rate, ctc_type, reduce)