code: def test_inference_base_model(self):
      model = LukeModel.from_pretrained("studio-ousia/luke-base").eval()
      model.to(torch_device)
  
      tokenizer = LukeTokenizer.from_pretrained(
          "studio-ousia/luke-base", task="entity_classification"
      )
      text = (
          "Top seed Ana Ivanovic said on Thursday she could hardly believe her luck as a fortuitous netcord helped"
          " the new world number one avoid a humiliating second- round exit at Wimbledon ."
      )
      span = (39, 42)
      encoding = tokenizer(
          text,
          entity_spans=[span],
          add_prefix_space=True,
          return_tensors="pt",
      )
  
      # move all values to device
      for key, value in encoding.items():
          encoding[key] = encoding[key].to(torch_device)
  
      outputs = model(**encoding)
  
      # Verify word hidden states
      expected_shape = torch.Size((1, 42, 768))
      self.assertEqual(outputs.last_hidden_state.shape, expected_shape)
  
      expected_slice = torch.tensor(
          [
              [0.0037, 0.1368, -0.0091],
              [0.1099, 0.3329, -0.1095],
              [0.0765, 0.5335, 0.1179],
          ]
      ).to(torch_device)
      self.assertTrue(
          torch.allclose(
              outputs.last_hidden_state[0, :3, :3],
              expected_slice,
              atol=1e-4,
          )
      )
  
      # Verify entity hidden states
      expected_shape = torch.Size((1, 1, 768))
      self.assertEqual(
          outputs.entity_last_hidden_state.shape, expected_shape
      )
  
      expected_slice = torch.tensor([[0.1457, 0.1044, 0.0174]]).to(
          torch_device
      )
      self.assertTrue(
          torch.allclose(
              outputs.entity_last_hidden_state[0, :3, :3],
              expected_slice,
              atol=1e-4,
          )
      )
  
imports: import unittest
  from transformers import LukeConfig, is_torch_available
  from transformers.testing_utils import require_torch, slow, torch_device
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
  from ...test_pipeline_mixin import PipelineTesterMixin
label_desc: Use image node_id 1 for calling the LukeModelIntegrationTests obj's underlying member method code with example usage: obj.test_inference_base_model() without return types