code: def test_inference_no_head(self):
      model = OneFormerModel.from_pretrained(self.model_checkpoints).to(
          torch_device
      )
      processor = self.default_processor
      image = prepare_img()
      inputs = processor(image, ["semantic"], return_tensors="pt").to(
          torch_device
      )
      inputs_shape = inputs["pixel_values"].shape
      # check size
      self.assertEqual(inputs_shape, (1, 3, 512, 682))
  
      task_inputs_shape = inputs["task_inputs"].shape
      # check size
      self.assertEqual(task_inputs_shape, (1, 77))
  
      with torch.no_grad():
          outputs = model(**inputs)
  
      expected_slice_hidden_state = torch.tensor(
          [
              [0.2723, 0.8280, 0.6026],
              [1.2699, 1.1257, 1.1444],
              [1.1344, 0.6153, 0.4177],
          ]
      ).to(torch_device)
      self.assertTrue(
          torch.allclose(
              outputs.encoder_hidden_states[-1][0, 0, :3, :3],
              expected_slice_hidden_state,
              atol=TOLERANCE,
          )
      )
  
      expected_slice_hidden_state = torch.tensor(
          [
              [1.0581, 1.2276, 1.2003],
              [1.1903, 1.2925, 1.2862],
              [1.158, 1.2559, 1.3216],
          ]
      ).to(torch_device)
      self.assertTrue(
          torch.allclose(
              outputs.pixel_decoder_hidden_states[0][0, 0, :3, :3],
              expected_slice_hidden_state,
              atol=TOLERANCE,
          )
      )
  
      expected_slice_hidden_state = torch.tensor(
          [
              [3.0668, -1.1833, -5.1103],
              [3.344, -3.362, -5.1101],
              [2.6017, -4.3613, -4.1444],
          ]
      ).to(torch_device)
      self.assertTrue(
          torch.allclose(
              outputs.transformer_decoder_class_predictions[0, :3, :3],
              expected_slice_hidden_state,
              atol=TOLERANCE,
          )
      )
  
imports: import copy
  import inspect
  import unittest
  import numpy
  from tests.test_modeling_common import floats_tensor
  from transformers import OneFormerConfig, 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 OneFormerModelIntegrationTest obj's underlying member method code with example usage: obj.test_inference_no_head() without return types