code: def _monotonic_alignment_search(log_p_attn):
      # https://arxiv.org/abs/2005.11129
      T_mel = log_p_attn.shape[0]
      T_inp = log_p_attn.shape[1]
      Q = np.full((T_inp, T_mel), fill_value=-np.inf)
  
      log_prob = log_p_attn.transpose(1, 0)  # -> (T_inp,T_mel)
      # 1.  Q <- init first row for all j
      for j in range(T_mel):
          Q[0, j] = log_prob[0, : j + 1].sum()
  
      # 2.
      for j in range(1, T_mel):
          for i in range(1, min(j + 1, T_inp)):
              Q[i, j] = (
                  max(Q[i - 1, j - 1], Q[i, j - 1]) + log_prob[i, j]
              )
  
      # 3.
      A = np.full((T_mel,), fill_value=T_inp - 1)
      for j in range(T_mel - 2, -1, -1):  # T_mel-2, ..., 0
          # 'i' in {A[j+1]-1, A[j+1]}
          i_a = A[j + 1] - 1
          i_b = A[j + 1]
          if i_b == 0:
              argmax_i = 0
          elif Q[i_a, j] >= Q[i_b, j]:
              argmax_i = i_a
          else:
              argmax_i = i_b
          A[j] = argmax_i
      return A
  
file_path: espnet/espnet2/gan_tts/jets/alignments.py
imports: import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from numba import jit
  from scipy.stats import betabinom
label_desc: Use image node_id 1 for calling a global function with example usage: _monotonic_alignment_search(log_p_attn) and returns: A