code: def test_hidden_states_output(self):
      def check_hidden_states_output(inputs_dict, config, model_class):
          model = model_class(config)
  
          outputs = model(
              **self._prepare_for_class(inputs_dict, model_class)
          )
          hidden_states = (
              outputs.encoder_hidden_states
              if config.is_encoder_decoder
              else outputs.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)
  
          if hasattr(self.model_tester, "encoder_seq_length"):
              seq_length = self.model_tester.encoder_seq_length
          else:
              seq_length = self.model_tester.seq_length
  
          self.assertListEqual(
              list(hidden_states[0].shape[-2:]),
              [seq_length, self.model_tester.hidden_size],
          )
  
          if config.is_encoder_decoder:
              hidden_states = outputs.decoder_hidden_states
  
              self.assertIsInstance(hidden_states, (list, tuple))
              self.assertEqual(len(hidden_states), expected_num_layers)
              seq_len = getattr(self.model_tester, "seq_length", None)
              decoder_seq_length = getattr(
                  self.model_tester, "decoder_seq_length", seq_len
              )
  
              self.assertListEqual(
                  list(hidden_states[0].shape[-2:]),
                  [decoder_seq_length, self.model_tester.hidden_size],
              )
  
      (
          config,
          inputs_dict,
      ) = self.model_tester.prepare_config_and_inputs_for_common()
  
      for model_class in self.all_model_classes:
          inputs_dict["output_hidden_states"] = True
          check_hidden_states_output(inputs_dict, config, model_class)
  
          # check that output_hidden_states also work using config
          del inputs_dict["output_hidden_states"]
          config.output_hidden_states = True
  
          check_hidden_states_output(inputs_dict, config, model_class)
  
imports: import copy
  import inspect
  import json
  import random
  import tempfile
  import unittest
  from typing import List, Tuple
  import numpy
  import transformers
  from huggingface_hub import HfFolder, delete_repo, set_access_token
  from requests.exceptions import HTTPError
  from transformers import BertConfig, is_flax_available, is_torch_available
  from transformers.models.auto import get_values
  from transformers.testing_utils import TOKEN, USER, CaptureLogger, is_pt_flax_cross_test, is_staging_test, require_flax, torch_device
  from transformers.utils import logging
  from transformers.utils.generic import ModelOutput
label_desc: Use image node_id 16 for calling the FlaxModelTesterMixin obj's underlying member method code with example usage: obj.test_hidden_states_output() without return types