class_docstr: CER and WER computation for Transducer model.
  
  Args:
      decoder: Decoder module.
      joint_network: Joint network module.
      token_list: Set of unique labels.
      sym_space: Space symbol.
      sym_blank: Blank symbol.
      report_cer: Whether to compute CER.
      report_wer: Whether to compute WER.
class_docstr_tok: ["CER","and","WER","computation","for","Transducer","model",".","Args",":","decoder",":","Decoder","module",".","joint_network",":","Joint","network","module",".","token_list",":","Set","of","unique","labels",".","sym_space",":","Space","symbol",".","sym_blank",":","Blank","symbol",".","report_cer",":","Whether","to","compute","CER",".","report_wer",":","Whether","to","compute","WER","."]
docstr: Calculate sentence-level WER score.
  
  Args:
      hyps: Hypotheses sequences. (B, L)
      refs: References sequences. (B, L)
  
  Returns:
      : Average sentence-level WER score.
docstr_tok: ["Calculate","sentence-level","WER","score",".","Args",":","hyps",":","Hypotheses","sequences",".","(","B",",","L",")","refs",":","References","sequences",".","(","B",",","L",")","Returns",":",":","Average","sentence-level","WER","score","."]
code: def calculate_wer(
      self, hyps: torch.Tensor, refs: torch.Tensor
  ) -> float:
      """Calculate sentence-level WER score.
  
      Args:
          hyps: Hypotheses sequences. (B, L)
          refs: References sequences. (B, L)
  
      Returns:
          : Average sentence-level WER score.
  
      """
      import editdistance
  
      distances, lens = [], []
  
      for i, hyp in enumerate(hyps):
          word_hyp = hyp.split()
          word_ref = refs[i].split()
  
          distances.append(editdistance.eval(word_hyp, word_ref))
          lens.append(len(word_ref))
  
      return float(sum(distances)) / sum(lens)
  
file_path: espnet/espnet/nets/pytorch_backend/transducer/error_calculator.py
imports: from typing import List, Tuple, Union
  import torch
  from espnet.nets.beam_search_transducer import BeamSearchTransducer
  from espnet.nets.pytorch_backend.transducer.custom_decoder import CustomDecoder
  from espnet.nets.pytorch_backend.transducer.joint_network import JointNetwork
  from espnet.nets.pytorch_backend.transducer.rnn_decoder import RNNDecoder
label_desc: Use image node_id 5 for calling the ErrorCalculator obj's underlying member method code with example usage: obj.calculate_wer(hyps, refs) and returns: unknown