code: def test_dropout_is_not_applied_to_output_or_returned_hidden_states(
      self,
  ):
      sorted_tensor, sorted_sequence, _, _ = sort_batch_by_length(
          self.random_tensor, self.sequence_lengths
      )
      tensor = pack_padded_sequence(
          sorted_tensor, sorted_sequence.data.tolist(), batch_first=True
      )
      lstm = AugmentedLstm(10, 11, recurrent_dropout_probability=0.5)
  
      output, (hidden_state, _) = lstm(tensor)
      output_sequence, _ = pad_packed_sequence(output, batch_first=True)
      # Test returned output sequence
      num_hidden_dims_zero_across_timesteps = (
          (output_sequence.sum(1) == 0).sum()
      ).item()
      # If this is not True then dropout has been applied to the output of the LSTM
      assert not num_hidden_dims_zero_across_timesteps
      # Should not have dropout applied to the last hidden state as this is not used
      # within the LSTM and makes it more consistent with the `torch.nn.LSTM` where
      # dropout is not applied to any of it's output. This would also make it more
      # consistent with the Keras LSTM implementation as well.
      hidden_state = hidden_state.squeeze()
      num_hidden_dims_zero_across_timesteps = (
          (hidden_state == 0).sum()
      ).item()
      assert not num_hidden_dims_zero_across_timesteps
  
imports: import pytest
  import numpy
  import torch
  import torch.nn.init
  from torch.nn.modules.rnn import LSTM
  from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.params import Params
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.modules.augmented_lstm import AugmentedLstm, AugmentedLSTMCell, BiAugmentedLstm
  from allennlp.nn import InitializerApplicator, Initializer
  from allennlp.nn.util import sort_batch_by_length
label_desc: Use image node_id 8 for calling the TestAugmentedLSTM obj's underlying member method code with example usage: obj.test_dropout_is_not_applied_to_output_or_returned_hidden_states() without return types