code: def test_dropout_works_for_training(self):
      layer_input_tensor = torch.FloatTensor([[2, 1], [-3, -2]])
      layer_output_tensor = torch.FloatTensor([[1, 3], [2, -1]])
  
      # The layer output should be dropped
      residual_with_layer_dropout = ResidualWithLayerDropout(1)
      residual_with_layer_dropout.train()
      result = residual_with_layer_dropout(
          layer_input_tensor, layer_output_tensor
      ).data.numpy()
      assert result.shape == (2, 2)
      assert_almost_equal(result, [[2, 1], [-3, -2]])
  
      result = residual_with_layer_dropout(
          layer_input_tensor, layer_output_tensor, 1, 1
      ).data.numpy()
      assert result.shape == (2, 2)
      assert_almost_equal(result, [[2, 1], [-3, -2]])
  
      # The layer output should not be dropped
      residual_with_layer_dropout = ResidualWithLayerDropout(0.0)
      residual_with_layer_dropout.train()
      result = residual_with_layer_dropout(
          layer_input_tensor, layer_output_tensor
      ).data.numpy()
      assert result.shape == (2, 2)
      assert_almost_equal(result, [[2 + 1, 1 + 3], [-3 + 2, -2 - 1]])
  
file_path: allennlp/tests/modules/residual_with_layer_dropout_test.py
imports: from numpy.testing import assert_almost_equal
  import torch
  from allennlp.modules import ResidualWithLayerDropout
  from allennlp.common.testing import AllenNlpTestCase
label_desc: Use image node_id 1 for calling the TestResidualWithLayerDropout obj's underlying member method code with example usage: obj.test_dropout_works_for_training() without return types