code: def test_inference_no_head(self):
      model = Mask2FormerModel.from_pretrained(
          self.model_checkpoints
      ).to(torch_device)
      image_processor = self.default_image_processor
      image = prepare_img()
      inputs = image_processor(image, return_tensors="pt").to(
          torch_device
      )
      inputs_shape = inputs["pixel_values"].shape
      # check size is divisible by 32
      self.assertTrue(
          (inputs_shape[-1] % 32) == 0 and (inputs_shape[-2] % 32) == 0
      )
      # check size
      self.assertEqual(inputs_shape, (1, 3, 384, 384))
  
      with torch.no_grad():
          outputs = model(**inputs)
  
      expected_slice_hidden_state = torch.tensor(
          [
              [-0.2790, -1.0717, -1.1668],
              [-0.5128, -0.3128, -0.4987],
              [-0.5832, 0.1971, -0.0197],
          ]
      ).to(torch_device)
      self.assertTrue(
          torch.allclose(
              outputs.encoder_last_hidden_state[0, 0, :3, :3],
              expected_slice_hidden_state,
              atol=TOLERANCE,
          )
      )
  
      expected_slice_hidden_state = torch.tensor(
          [
              [0.8973, 1.1847, 1.1776],
              [1.1934, 1.5040, 1.5128],
              [1.1153, 1.4486, 1.4951],
          ]
      ).to(torch_device)
      self.assertTrue(
          torch.allclose(
              outputs.pixel_decoder_last_hidden_state[0, 0, :3, :3],
              expected_slice_hidden_state,
              atol=TOLERANCE,
          )
      )
  
      expected_slice_hidden_state = torch.tensor(
          [
              [2.1152, 1.7000, -0.8603],
              [1.5808, 1.8004, -0.9353],
              [1.6043, 1.7495, -0.5999],
          ]
      ).to(torch_device)
      self.assertTrue(
          torch.allclose(
              outputs.transformer_decoder_last_hidden_state[0, :3, :3],
              expected_slice_hidden_state,
              atol=TOLERANCE,
          )
      )
  
imports: import unittest
  import numpy
  from tests.test_modeling_common import floats_tensor
  from transformers import Mask2FormerConfig, is_torch_available, is_vision_available
  from transformers.testing_utils import require_torch, require_torch_accelerator, require_torch_fp16, require_torch_multi_gpu, require_vision, slow, torch_device
  from transformers.utils import cached_property
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin
  from ...test_pipeline_mixin import PipelineTesterMixin
label_desc: Use image node_id 3 for calling the Mask2FormerModelIntegrationTest obj's underlying member method code with example usage: obj.test_inference_no_head() without return types