class_docstr: This is WERBPE_TS class that is modified for generating word_timestamps with logits.
  The functions in WER class is modified to save the word_timestamps whenever BPE token
  is being saved into a list.
  This class is designed to support ASR models based on CTC and BPE.
  Please refer to the definition of WERBPE class for more information.
class_docstr_tok: ["This","is","WERBPE_TS","class","that","is","modified","for","generating","word_timestamps","with","logits",".","The","functions","in","WER","class","is","modified","to","save","the","word_timestamps","whenever","BPE","token","is","being","saved","into","a","list",".","This","class","is","designed","to","support","ASR","models","based","on","CTC","and","BPE",".","Please","refer","to","the","definition","of","WERBPE","class","for","more","information","."]
code: def get_ts_from_decoded_prediction(
      self,
      decoded_prediction: List[str],
      hypothesis: str,
      char_ts: List[str],
  ) -> Tuple[List[List[float]], List[str]]:
      decoded_char_list = self.decoding.tokenizer.ids_to_tokens(
          decoded_prediction
      )
      stt_idx, end_idx = 0, len(decoded_char_list) - 1
      stt_ch_idx, end_ch_idx = 0, 0
      space = "▁"
      word_ts, word_seq = [], []
      word_open_flag = False
      for idx, ch in enumerate(decoded_char_list):
          # If the symbol is space and not an end of the utterance, move on
          if idx != end_idx and (
              space == ch and space in decoded_char_list[idx + 1]
          ):
              continue
  
          # If the word does not containg space (the start of the word token), keep counting
          if (
              idx == stt_idx
              or space == decoded_char_list[idx - 1]
              or (space in ch and len(ch) > 1)
          ) and (ch != space):
              _stt = char_ts[idx]
              stt_ch_idx = idx
              word_open_flag = True
  
          # If this char has `word_open_flag=True` and meets any of one of the following condition:
          # (1) last word (2) unknown word (3) start symbol in the following word,
          # close the `word_open_flag` and add the word to the `word_seq` list.
          close_cond = (
              idx == end_idx
              or ch in ["<unk>"]
              or space in decoded_char_list[idx + 1]
          )
          if (word_open_flag and ch != space) and close_cond:
              _end = round(char_ts[idx] + self.time_stride, 2)
              end_ch_idx = idx
              word_open_flag = False
              word_ts.append([_stt, _end])
              stitched_word = "".join(
                  decoded_char_list[stt_ch_idx : end_ch_idx + 1]
              ).replace(space, "")
              word_seq.append(stitched_word)
  
      assert len(word_ts) == len(
          hypothesis.split()
      ), "Text hypothesis does not match word timestamps."
      return word_ts, word_seq
  
imports: import copy
  import math
  from typing import Dict, List, Tuple, Type, Union
  import numpy
  import torch
  from omegaconf import OmegaConf
  import nemo.collections.asr
  from nemo.collections.asr.metrics.wer import WER
  from nemo.collections.asr.models import EncDecCTCModel, EncDecCTCModelBPE
  from nemo.collections.asr.parts.submodules.ctc_decoding import CTCBPEDecoding, CTCBPEDecodingConfig, CTCDecoding, CTCDecodingConfig
  from nemo.collections.asr.parts.utils.audio_utils import get_samples
  from nemo.collections.asr.parts.utils.speaker_utils import audio_rttm_map, get_uniqname_from_filepath
  from nemo.collections.asr.parts.utils.streaming_utils import AudioFeatureIterator, FrameBatchASR
  from nemo.collections.common.tokenizers.tokenizer_spec import TokenizerSpec
  from nemo.utils import logging
label_desc: Use image node_id 5 for calling the WERBPE_TS obj's underlying member method code with example usage: obj.get_ts_from_decoded_prediction(decoded_prediction, hypothesis, char_ts) and returns: word_ts,  word_seq