class_docstr: Calculate CER and WER for transducer models.
  
  Args:
      decoder: Decoder module.
      joint_network: Joint Network module.
      token_list: List of token units.
      sym_space: Space symbol.
      sym_blank: Blank symbol.
      nstep: Maximum number of symbol expansions at each time step w/ mAES.
      report_cer: Whether to compute CER.
      report_wer: Whether to compute WER.
class_docstr_tok: ["Calculate","CER","and","WER","for","transducer","models",".","Args",":","decoder",":","Decoder","module",".","joint_network",":","Joint","Network","module",".","token_list",":","List","of","token","units",".","sym_space",":","Space","symbol",".","sym_blank",":","Blank","symbol",".","nstep",":","Maximum","number","of","symbol","expansions","at","each","time","step","w\/","mAES",".","report_cer",":","Whether","to","compute","CER",".","report_wer",":","Whether","to","compute","WER","."]
docstr: Calculate sentence-level CER score.
  
  Args:
      char_pred: Prediction character sequences. (B, ?)
      char_target: Target character sequences. (B, ?)
  
  Returns:
      : Average sentence-level CER score.
docstr_tok: ["Calculate","sentence-level","CER","score",".","Args",":","char_pred",":","Prediction","character","sequences",".","(","B",",","?",")","char_target",":","Target","character","sequences",".","(","B",",","?",")","Returns",":",":","Average","sentence-level","CER","score","."]
code: def calculate_cer(
      self, char_pred: torch.Tensor, char_target: torch.Tensor
  ) -> float:
      """Calculate sentence-level CER score.
  
      Args:
          char_pred: Prediction character sequences. (B, ?)
          char_target: Target character sequences. (B, ?)
  
      Returns:
          : Average sentence-level CER score.
  
      """
      import editdistance
  
      distances, lens = [], []
  
      for i, char_pred_i in enumerate(char_pred):
          pred = char_pred_i.replace(" ", "")
          target = char_target[i].replace(" ", "")
  
          distances.append(editdistance.eval(pred, target))
          lens.append(len(target))
  
      return float(sum(distances)) / sum(lens)
  
file_path: espnet/espnet2/asr_transducer/error_calculator.py
imports: from typing import List, Optional, Tuple
  import torch
  from espnet2.asr_transducer.beam_search_transducer import BeamSearchTransducer
  from espnet2.asr_transducer.decoder.abs_decoder import AbsDecoder
  from espnet2.asr_transducer.joint_network import JointNetwork
label_desc: Use image node_id 4 for calling the ErrorCalculator obj's underlying member method code with example usage: obj.calculate_cer(char_pred, char_target) and returns: unknown