code: def test_small_model_pt(self):
      model_name = (
          "hf-internal-testing/tiny-bert-for-token-classification"
      )
      token_classifier = pipeline(
          task="token-classification", model=model_name, framework="pt"
      )
      outputs = token_classifier("This is a test !")
      self.assertEqual(
          nested_simplify(outputs),
          [
              {
                  "entity": "I-MISC",
                  "score": 0.115,
                  "index": 1,
                  "word": "this",
                  "start": 0,
                  "end": 4,
              },
              {
                  "entity": "I-MISC",
                  "score": 0.115,
                  "index": 2,
                  "word": "is",
                  "start": 5,
                  "end": 7,
              },
          ],
      )
  
      token_classifier = pipeline(
          task="token-classification",
          model=model_name,
          framework="pt",
          ignore_labels=["O", "I-MISC"],
      )
      outputs = token_classifier("This is a test !")
      self.assertEqual(
          nested_simplify(outputs),
          [],
      )
  
      token_classifier = pipeline(
          task="token-classification", model=model_name, framework="pt"
      )
      # Overload offset_mapping
      outputs = token_classifier(
          "This is a test !",
          offset_mapping=[
              (0, 0),
              (0, 1),
              (0, 2),
              (0, 0),
              (0, 0),
              (0, 0),
              (0, 0),
          ],
      )
      self.assertEqual(
          nested_simplify(outputs),
          [
              {
                  "entity": "I-MISC",
                  "score": 0.115,
                  "index": 1,
                  "word": "this",
                  "start": 0,
                  "end": 1,
              },
              {
                  "entity": "I-MISC",
                  "score": 0.115,
                  "index": 2,
                  "word": "is",
                  "start": 0,
                  "end": 2,
              },
          ],
      )
  
      # Batch size does not affect outputs (attention_mask are required)
      sentences = [
          "This is a test !",
          "Another test this is with longer sentence",
      ]
      outputs = token_classifier(sentences)
      outputs_batched = token_classifier(sentences, batch_size=2)
      # Batching does not make a difference in predictions
      self.assertEqual(
          nested_simplify(outputs_batched), nested_simplify(outputs)
      )
      self.assertEqual(
          nested_simplify(outputs_batched),
          [
              [
                  {
                      "entity": "I-MISC",
                      "score": 0.115,
                      "index": 1,
                      "word": "this",
                      "start": 0,
                      "end": 4,
                  },
                  {
                      "entity": "I-MISC",
                      "score": 0.115,
                      "index": 2,
                      "word": "is",
                      "start": 5,
                      "end": 7,
                  },
              ],
              [],
          ],
      )
  
imports: import unittest
  import numpy
  from transformers import MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING, TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING, AutoModelForTokenClassification, AutoTokenizer, TokenClassificationPipeline, pipeline
  from transformers.pipelines import AggregationStrategy, TokenClassificationArgumentHandler
  from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, require_torch_accelerator, slow, torch_device
  from .test_pipelines_common import ANY
label_desc: Use image node_id 19 for calling the TokenClassificationPipelineTests obj's underlying member method code with example usage: obj.test_small_model_pt() without return types