class_docstr: Module for alignment text and mel spectrogram.
  
  Args:
      n_mel_channels: Dimension of mel spectrogram.
      n_text_channels: Dimension of text embeddings.
      n_att_channels: Dimension of model
      temperature: Temperature to scale distance by.
          Suggested to be 0.0005 when using dist_type "l2" and 15.0 when using "cosine".
      condition_types: List of types for nemo.collections.tts.modules.submodules.ConditionalInput.
      dist_type: Distance type to use for similarity measurement. Supports "l2" and "cosine" distance.
class_docstr_tok: ["Module","for","alignment","text","and","mel","spectrogram",".","Args",":","n_mel_channels",":","Dimension","of","mel","spectrogram",".","n_text_channels",":","Dimension","of","text","embeddings",".","n_att_channels",":","Dimension","of","model","temperature",":","Temperature","to","scale","distance","by",".","Suggested","to","be","0.0005","when","using","dist_type","``","l2","''","and","15.0","when","using","``","cosine","''",".","condition_types",":","List","of","types","for","nemo.collections.tts.modules.submodules.ConditionalInput",".","dist_type",":","Distance","type","to","use","for","similarity","measurement",".","Supports","``","l2","''","and","``","cosine","''","distance","."]
docstr: Calculates the mean distance between text and audio embeddings given a range of text tokens.
  
  Args:
      l2_dists (torch.tensor): L2 distance matrix from Aligner inference. T1 x T2 tensor.
      durs (torch.tensor): List of durations corresponding to each text token. T2 tensor. Should sum to T1.
      start_token (int): Index of the starting token for the word of interest.
      num_tokens (int): Length (in tokens) of the word of interest.
  Output:
      mean_dist_for_word (float): Mean embedding distance between the word indicated and its predicted audio frames.
docstr_tok: ["Calculates","the","mean","distance","between","text","and","audio","embeddings","given","a","range","of","text","tokens",".","Args",":","l2_dists","(","torch.tensor",")",":","L2","distance","matrix","from","Aligner","inference",".","T1","x","T2","tensor",".","durs","(","torch.tensor",")",":","List","of","durations","corresponding","to","each","text","token",".","T2","tensor",".","Should","sum","to","T1",".","start_token","(","int",")",":","Index","of","the","starting","token","for","the","word","of","interest",".","num_tokens","(","int",")",":","Length","(","in","tokens",")","of","the","word","of","interest",".","Output",":","mean_dist_for_word","(","float",")",":","Mean","embedding","distance","between","the","word","indicated","and","its","predicted","audio","frames","."]
code: def get_mean_distance_for_word(
      l2_dists, durs, start_token, num_tokens
  ):
      """Calculates the mean distance between text and audio embeddings given a range of text tokens.
  
      Args:
          l2_dists (torch.tensor): L2 distance matrix from Aligner inference. T1 x T2 tensor.
          durs (torch.tensor): List of durations corresponding to each text token. T2 tensor. Should sum to T1.
          start_token (int): Index of the starting token for the word of interest.
          num_tokens (int): Length (in tokens) of the word of interest.
      Output:
          mean_dist_for_word (float): Mean embedding distance between the word indicated and its predicted audio frames.
      """
      # Need to calculate which audio frame we start on by summing all durations up to the start token's duration
      start_frame = torch.sum(durs[:start_token]).data
  
      total_frames = 0
      dist_sum = 0
  
      # Loop through each text token
      for token_ind in range(start_token, start_token + num_tokens):
          # Loop through each frame for the given text token
          for frame_ind in range(
              start_frame, start_frame + durs[token_ind]
          ):
              # Recall that the L2 distance matrix is shape [spec_len, text_len]
              dist_sum += l2_dists[frame_ind, token_ind]
  
          # Update total frames so far & the starting frame for the next token
          total_frames += durs[token_ind]
          start_frame += durs[token_ind]
  
      return dist_sum / total_frames
  
file_path: NeMo/nemo/collections/tts/modules/aligner.py
imports: import torch
  from einops import rearrange
  from torch import nn
  from nemo.collections.tts.modules.submodules import ConditionalInput, ConvNorm
  from nemo.collections.tts.parts.utils.helpers import binarize_attention_parallel
label_desc: Use image node_id 8 for calling the AlignmentEncoder obj's underlying member method code with example usage: obj.get_mean_distance_for_word(l2_dists, durs, start_token, num_tokens) and returns: unknown