code: def length_to_mask(length, max_len=None, dtype=None):
      assert len(length.shape) == 1
  
      if max_len is None:
          max_len = (
              length.max().astype("int").item()
          )  # using arange to generate mask
      mask = paddle.arange(max_len, dtype=length.dtype).expand(
          (len(length), max_len)
      ) < length.unsqueeze(1)
  
      if dtype is None:
          dtype = length.dtype
  
      mask = paddle.to_tensor(mask, dtype=dtype)
      return mask
  
imports: import math
  import os
  import paddle
  import paddle.nn
  import paddle.nn.functional
label_desc: Use image node_id 1 for calling a global function with example usage: length_to_mask(length, max_len, dtype) and returns: mask