code: def test_get_mask_from_sequence_lengths(self):
      sequence_lengths = torch.LongTensor([4, 3, 1, 4, 2])
      mask = util.get_mask_from_sequence_lengths(
          sequence_lengths, 5
      ).data.numpy()
      assert_almost_equal(
          mask,
          [
              [1, 1, 1, 1, 0],
              [1, 1, 1, 0, 0],
              [1, 0, 0, 0, 0],
              [1, 1, 1, 1, 0],
              [1, 1, 0, 0, 0],
          ],
      )
  
imports: from __future__ import with_statement
  from __future__ import division
  from __future__ import absolute_import
  import numpy
  from numpy.testing import assert_array_almost_equal, assert_almost_equal
  import torch
  import pytest
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.nn import util
label_desc: Use image node_id 2 for calling the TestNnUtil obj's underlying member method code with example usage: obj.test_get_mask_from_sequence_lengths() without return types