code: def test_get_sequence_lengths_converts_to_long_tensor_and_avoids_variable_overflow(
      self,
  ):
      # Tests the following weird behaviour in Pytorch 0.1.12
      # doesn't happen for our sequence masks:
      #
      # mask = torch.ones([260]).byte()
      # mask.sum() # equals 260.
      # var_mask = t.a.V(mask)
      # var_mask.sum() # equals 4, due to 8 bit precision - the sum overflows.
      binary_mask = torch.ones(2, 260).byte()
      lengths = util.get_lengths_from_binary_sequence_mask(binary_mask)
      numpy.testing.assert_array_equal(
          lengths.data.numpy(), numpy.array([260, 260])
      )
  
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 3 for calling the TestNnUtil obj's underlying member method code with example usage: obj.test_get_sequence_lengths_converts_to_long_tensor_and_avoids_variable_overflow() without return types