code: def _lengths_to_padding_mask(lengths: torch.Tensor) -> torch.Tensor:
      batch_size = lengths.shape[0]
      max_length = int(torch.max(lengths).item())
      padding_mask = torch.arange(
          max_length, device=lengths.device, dtype=lengths.dtype
      ).expand(batch_size, max_length) >= lengths.unsqueeze(1)
      return padding_mask
  
imports: import math
  from typing import List, Optional, Tuple
  import torch
label_desc: Use image node_id 1 for calling a global function with example usage: _lengths_to_padding_mask(lengths) and returns: padding_mask