class_docstr: Calculate CER and WER for E2E_ASR and CTC models during training.
  
  :param y_hats: numpy array with predicted text
  :param y_pads: numpy array with true (target) text
  :param char_list:
  :param sym_space:
  :param sym_blank:
  :return:
docstr: Convert index to character.
  
  :param torch.Tensor seqs_hat: prediction (batch, seqlen)
  :param torch.Tensor seqs_true: reference (batch, seqlen)
  :return: token list of prediction
  :rtype list
  :return: token list of reference
  :rtype list
docstr_tok: ["Convert","index","to","character",".",":","param","torch.Tensor","seqs_hat",":","prediction","(","batch",",","seqlen",")",":","param","torch.Tensor","seqs_true",":","reference","(","batch",",","seqlen",")",":","return",":","token","list","of","prediction",":","rtype","list",":","return",":","token","list","of","reference",":","rtype","list"]
code: def convert_to_char(self, ys_hat, ys_pad):
      """Convert index to character.
  
      :param torch.Tensor seqs_hat: prediction (batch, seqlen)
      :param torch.Tensor seqs_true: reference (batch, seqlen)
      :return: token list of prediction
      :rtype list
      :return: token list of reference
      :rtype list
      """
      seqs_hat, seqs_true = [], []
      for i, y_hat in enumerate(ys_hat):
          y_true = ys_pad[i]
          eos_true = np.where(y_true == -1)[0]
          ymax = eos_true[0] if len(eos_true) > 0 else len(y_true)
          # NOTE: padding index (-1) in y_true is used to pad y_hat
          seq_hat = [self.char_list[int(idx)] for idx in y_hat[:ymax]]
          seq_true = [
              self.char_list[int(idx)]
              for idx in y_true
              if int(idx) != -1
          ]
          seq_hat_text = "".join(seq_hat).replace(self.space, " ")
          seq_hat_text = seq_hat_text.replace(self.blank, "")
          seq_true_text = "".join(seq_true).replace(self.space, " ")
          seqs_hat.append(seq_hat_text)
          seqs_true.append(seq_true_text)
      return seqs_hat, seqs_true
  
file_path: espnet/espnet/nets/e2e_asr_common.py
imports: import json
  import logging
  import sys
  from itertools import groupby
  import numpy
label_desc: Use image node_id 4 for calling the ErrorCalculator obj's underlying member method code with example usage: obj.convert_to_char(ys_hat, ys_pad) and returns: seqs_hat,  seqs_true