code: def check_hidden_states_output(
      self, inputs_dict, config, model_class, image_size
  ):
      model = model_class(config)
      model.to(torch_device)
      model.eval()
  
      with torch.no_grad():
          outputs = model(
              **self._prepare_for_class(inputs_dict, model_class)
          )
  
      hidden_states = outputs.hidden_states
  
      expected_num_layers = getattr(
          self.model_tester,
          "expected_num_hidden_layers",
          len(self.model_tester.depths) + 1,
      )
      self.assertEqual(len(hidden_states), expected_num_layers)
  
      # DonutSwin has a different seq_length
      patch_size = (
          config.patch_size
          if isinstance(config.patch_size, collections.abc.Iterable)
          else (config.patch_size, config.patch_size)
      )
  
      num_patches = (image_size[1] // patch_size[1]) * (
          image_size[0] // patch_size[0]
      )
  
      self.assertListEqual(
          list(hidden_states[0].shape[-2:]),
          [num_patches, self.model_tester.embed_dim],
      )
  
      reshaped_hidden_states = outputs.reshaped_hidden_states
      self.assertEqual(len(reshaped_hidden_states), expected_num_layers)
  
      batch_size, num_channels, height, width = reshaped_hidden_states[
          0
      ].shape
      reshaped_hidden_states = (
          reshaped_hidden_states[0]
          .view(batch_size, num_channels, height * width)
          .permute(0, 2, 1)
      )
      self.assertListEqual(
          list(reshaped_hidden_states.shape[-2:]),
          [num_patches, self.model_tester.embed_dim],
      )
  
imports: import collections
  import inspect
  import unittest
  from transformers import DonutSwinConfig
  from transformers.testing_utils import require_torch, slow, torch_device
  from transformers.utils import is_torch_available
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
label_desc: Use image node_id 9 for calling the DonutSwinModelTest obj's underlying member method code with example usage: obj.check_hidden_states_output(inputs_dict, config, model_class, image_size) without return types