code: def make_seq_mask_like(
      like: torch.Tensor,
      lengths: torch.Tensor,
      valid_ones: bool = True,
      time_dim: int = -1,
  ) -> torch.Tensor:
      mask = (
          torch.arange(like.shape[time_dim], device=like.device)
          .repeat(lengths.shape[0], 1)
          .lt(lengths.unsqueeze(-1))
      )
      # Match number of dims in `like` tensor
      for _ in range(like.dim() - mask.dim()):
          mask = mask.unsqueeze(1)
      # If time dim != -1, transpose to proper dim.
      if time_dim != -1:
          mask = mask.transpose(time_dim, -1)
      if not valid_ones:
          mask = ~mask
      return mask
  
imports: from typing import List
  import torch
  from numpy import inf
  from torch import nn
  from torch.nn import functional
  from nemo.collections.asr.parts.submodules.jasper import get_same_padding, init_weights
label_desc: Use image node_id 1 for calling a global function with example usage: make_seq_mask_like(like, lengths, valid_ones, time_dim) and returns: mask