class_docstr: Calculate BLEU for ST and MT models during training.
  
  :param y_hats: numpy array with predicted text
  :param y_pads: numpy array with true (target) text
  :param char_list: vocabulary list
  :param sym_space: space symbol
  :param sym_pad: pad symbol
  :param report_bleu: report BLUE score if True
docstr: Calculate sentence-level BLEU score for CTC.
  
  :param torch.Tensor ys_hat: prediction (batch, seqlen)
  :param torch.Tensor ys_pad: reference (batch, seqlen)
  :return: corpus-level BLEU score
  :rtype float
code: def calculate_bleu_ctc(self, ys_hat, ys_pad):
      """Calculate sentence-level BLEU score for CTC.
  
      :param torch.Tensor ys_hat: prediction (batch, seqlen)
      :param torch.Tensor ys_pad: reference (batch, seqlen)
      :return: corpus-level BLEU score
      :rtype float
      """
      seqs_hat, seqs_true = [], []
      for i, y in enumerate(ys_hat):
          y_hat = [x[0] for x in groupby(y)]
          y_true = ys_pad[i]
          seq_hat, seq_true = [], []
          for idx in y_hat:
              idx = int(idx)
              if (
                  idx != -1
                  and idx != self.idx_blank
                  and idx != self.idx_space
              ):
                  seq_hat.append(self.char_list[int(idx)])
  
          for idx in y_true:
              idx = int(idx)
              if (
                  idx != -1
                  and idx != self.idx_blank
                  and idx != self.idx_space
              ):
                  seq_true.append(self.char_list[int(idx)])
  
          seq_hat_text = "".join(seq_hat).replace(self.space, " ")
          seq_hat_text = seq_hat_text.replace(self.pad, "")
          seq_true_text = "".join(seq_true).replace(self.space, " ")
          seqs_hat.append(seq_hat_text)
          seqs_true.append(seq_true_text)
  
      bleu = nltk.bleu_score.corpus_bleu(
          [[ref] for ref in seqs_true], seqs_hat
      )
      return bleu
  
file_path: espnet/espnet/nets/e2e_mt_common.py
imports: from itertools import groupby
  import nltk
  import numpy
label_desc: Use image node_id 4 for calling the ErrorCalculator obj's underlying member method code with example usage: obj.calculate_bleu_ctc(ys_hat, ys_pad) and returns: bleu