code: def test_hidden_states_output(self):
      def _check_hidden_states_output(inputs_dict, config, model_class):
          model = model_class(config)
          model.to(torch_device)
          model.eval()
  
          with torch.no_grad():
              outputs = model(
                  **self._prepare_for_class(inputs_dict, model_class)
              )
  
          for idx, hidden_states in enumerate(
              [
                  outputs.encoder_hidden_states,
                  outputs.decoder_hidden_states,
              ]
          ):
              expected_num_layers = getattr(
                  self.model_tester,
                  "expected_num_hidden_layers",
                  self.model_tester.num_hidden_layers + 1,
              )
  
              self.assertEqual(len(hidden_states), expected_num_layers)
              self.assertIsInstance(hidden_states, (list, tuple))
              (
                  expected_batch_size,
                  expected_seq_length,
                  expected_hidden_size,
              ) = hidden_states[0].shape
              self.assertEqual(
                  expected_batch_size, self.model_tester.batch_size
              )
              # Only test encoder seq_length since decoder seq_length is variable based on inputs
              if idx == 0:
                  self.assertEqual(
                      expected_seq_length, self.model_tester.seq_length
                  )
              self.assertEqual(
                  expected_hidden_size, self.model_tester.hidden_size
              )
  
      (
          config,
          inputs_dict,
      ) = self.model_tester.prepare_config_and_inputs_for_common()
  
      inputs_dict["output_hidden_states"] = True
      _check_hidden_states_output(
          inputs_dict, config, FastSpeech2ConformerWithHifiGan
      )
  
      # check that output_hidden_states also work using config
      del inputs_dict["output_hidden_states"]
      config.model_config.output_hidden_states = True
  
      _check_hidden_states_output(
          inputs_dict, config, FastSpeech2ConformerWithHifiGan
      )
  
imports: import inspect
  import tempfile
  import unittest
  from transformers import FastSpeech2ConformerConfig, FastSpeech2ConformerHifiGanConfig, FastSpeech2ConformerTokenizer, FastSpeech2ConformerWithHifiGanConfig, is_torch_available
  from transformers.testing_utils import require_g2p_en, require_torch, slow, torch_device
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, _config_zero_init, ids_tensor
label_desc: Use image node_id 6 for calling the FastSpeech2ConformerWithHifiGanTest obj's underlying member method code with example usage: obj.test_hidden_states_output() without return types