def update(self, encoder_output: torch.Tensor, encoded_lengths: torch.Tensor, targets: torch.Tensor, target_lengths: torch.Tensor) -> torch.Tensor:
    words = 0.0
    scores = 0.0
    references = []
    with torch.no_grad():
        targets_cpu_tensor = targets.long().cpu()
        tgt_lenths_cpu_tensor = target_lengths.long().cpu()
        for ind in range(targets_cpu_tensor.shape[self.batch_dim_index]):
            tgt_len = tgt_lenths_cpu_tensor[ind].item()
            target = targets_cpu_tensor[ind][:tgt_len].numpy().tolist()
            reference = self.decoding.decode_tokens_to_str(target)
            references.append(reference)
        (hypotheses, _) = self.decoding.rnnt_decoder_predictions_tensor(encoder_output, encoded_lengths)
    if self.log_prediction:
        logging.info(f'''
''')
        logging.info(f'reference :{references[0]}')
        logging.info(f'predicted :{hypotheses[0]}')
    for (h, r) in zip(hypotheses, references):
        if self.use_cer:
            h_list = list(h)
            r_list = list(r)
        else:
            h_list = h.split()
            r_list = r.split()
        words += len(r_list)
        scores += editdistance.eval(h_list, r_list)
    self.scores += torch.tensor(scores, device=self.scores.device, dtype=self.scores.dtype)
    self.words += torch.tensor(words, device=self.words.device, dtype=self.words.dtype)
def update(self, encoder_output: torch.Tensor, encoded_lengths: torch.Tensor, targets: torch.Tensor, target_lengths: torch.Tensor) -> torch.Tensor:
    words = 0.0
    scores = 0.0
    references = []
    with torch.no_grad():
        targets_cpu_tensor = targets.long().cpu()
        tgt_lenths_cpu_tensor = target_lengths.long().cpu()
        for ind in range(targets_cpu_tensor.shape[self.batch_dim_index]):
            tgt_len = tgt_lenths_cpu_tensor[ind].item()
            target = targets_cpu_tensor[ind][:tgt_len].numpy().tolist()
            reference = self.decoding.decode_tokens_to_str(target)
            references.append(reference)
        (hypotheses, _) = self.decoding.rnnt_decoder_predictions_tensor(encoder_output, encoded_lengths)
    if self.log_prediction:
        logging.info(f'
')
        logging.info(f'reference :{references[0]}')
        logging.info(f'predicted :{hypotheses[0]}')
    for (h, r) in zip(hypotheses, references):
        if self.use_cer:
            h_list = list(h)
            r_list = list(r)
        else:
            h_list = h.split()
            r_list = r.split()
        words += len(r_list)
        scores += editdistance.eval(h_list, r_list)
    self.scores += torch.tensor(scores, device=self.scores.device, dtype=self.scores.dtype)
    self.words += torch.tensor(words, device=self.words.device, dtype=self.words.dtype)