code: def generate_path(duration, mask):
      """
      duration: [b, 1, t_x]
      mask: [b, 1, t_y, t_x]
      """
      b, _, t_y, t_x = mask.shape
      cum_duration = torch.cumsum(duration, -1)
  
      cum_duration_flat = cum_duration.view(b * t_x)
      path = get_mask_from_lengths(
          cum_duration_flat, torch.Tensor(t_y).reshape(1, 1, -1)
      ).to(mask.dtype)
      path = path.view(b, t_x, t_y)
      path = (
          path
          - torch.nn.functional.pad(
              path, convert_pad_shape([[0, 0], [1, 0], [0, 0]])
          )[:, :-1]
      )
      path = path.unsqueeze(1).transpose(2, 3) * mask
      return path
  
imports: from enum import Enum
  from typing import Optional, Tuple
  import librosa
  import matplotlib.pylab
  import numpy
  import torch
  from einops import rearrange
  from numba import jit, prange
  from nemo.collections.tts.torch.tts_data_types import DATA_STR2DATA_CLASS, MAIN_DATA_TYPES, WithLens
  from nemo.utils import logging
  from nemo.utils.decorators import deprecated
label_desc: Use image node_id 30 for calling a global function with example usage: generate_path(duration, mask) and returns: path