code: def test_remove_sentence_boundaries(self):
      tensor = torch.from_numpy(numpy.random.rand(3, 5, 7))
      mask = torch.from_numpy(
          # The mask with two elements is to test the corner case
          # of an empty sequence, so here we are removing boundaries
          # from  "<S> </S>"
          numpy.array(
              [[1, 1, 0, 0, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 0]]
          )
      ).long()
      new_tensor, new_mask = util.remove_sentence_boundaries(
          tensor, mask
      )
  
      expected_new_tensor = torch.zeros(3, 3, 7)
      expected_new_tensor[1, 0:3, :] = tensor[1, 1:4, :]
      expected_new_tensor[2, 0:2, :] = tensor[2, 1:3, :]
      assert_array_almost_equal(
          new_tensor.data.numpy(), expected_new_tensor.data.numpy()
      )
  
      expected_new_mask = torch.from_numpy(
          numpy.array([[0, 0, 0], [1, 1, 1], [1, 1, 0]])
      ).long()
      assert (
          new_mask.data.numpy() == expected_new_mask.data.numpy()
      ).all()
  
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 33 for calling the TestNnUtil obj's underlying member method code with example usage: obj.test_remove_sentence_boundaries() without return types