code: def test_aggregation_strategy_example2(self):
      model_name = "sshleifer/tiny-dbmdz-bert-large-cased-finetuned-conll03-english"
      tokenizer = AutoTokenizer.from_pretrained(
          model_name, use_fast=True
      )
      token_classifier = pipeline(
          task="ner",
          model=model_name,
          tokenizer=tokenizer,
          framework="pt",
      )
      # Just to understand scores indexes in this test
      self.assertEqual(
          token_classifier.model.config.id2label,
          {
              0: "O",
              1: "B-MISC",
              2: "I-MISC",
              3: "B-PER",
              4: "I-PER",
              5: "B-ORG",
              6: "I-ORG",
              7: "B-LOC",
              8: "I-LOC",
          },
      )
      example = [
          {
              # Necessary for AVERAGE
              "scores": np.array([0, 0.55, 0, 0.45, 0, 0, 0, 0, 0, 0]),
              "is_subword": False,
              "index": 1,
              "word": "Ra",
              "start": 0,
              "end": 2,
          },
          {
              "scores": np.array([0, 0, 0, 0.2, 0, 0, 0, 0.8, 0, 0]),
              "is_subword": True,
              "word": "##ma",
              "start": 2,
              "end": 4,
              "index": 2,
          },
          {
              # 4th score will have the higher average
              # 4th score is B-PER for this model
              # It's does not correspond to any of the subtokens.
              "scores": np.array([0, 0, 0, 0.4, 0, 0, 0.6, 0, 0, 0]),
              "is_subword": True,
              "word": "##zotti",
              "start": 11,
              "end": 13,
              "index": 3,
          },
      ]
      self.assertEqual(
          token_classifier.aggregate(example, AggregationStrategy.NONE),
          [
              {
                  "end": 2,
                  "entity": "B-MISC",
                  "score": 0.55,
                  "start": 0,
                  "word": "Ra",
                  "index": 1,
              },
              {
                  "end": 4,
                  "entity": "B-LOC",
                  "score": 0.8,
                  "start": 2,
                  "word": "##ma",
                  "index": 2,
              },
              {
                  "end": 13,
                  "entity": "I-ORG",
                  "score": 0.6,
                  "start": 11,
                  "word": "##zotti",
                  "index": 3,
              },
          ],
      )
  
      self.assertEqual(
          token_classifier.aggregate(
              example, AggregationStrategy.FIRST
          ),
          [
              {
                  "entity_group": "MISC",
                  "score": 0.55,
                  "word": "Ramazotti",
                  "start": 0,
                  "end": 13,
              }
          ],
      )
      self.assertEqual(
          token_classifier.aggregate(example, AggregationStrategy.MAX),
          [
              {
                  "entity_group": "LOC",
                  "score": 0.8,
                  "word": "Ramazotti",
                  "start": 0,
                  "end": 13,
              }
          ],
      )
      self.assertEqual(
          nested_simplify(
              token_classifier.aggregate(
                  example, AggregationStrategy.AVERAGE
              )
          ),
          [
              {
                  "entity_group": "PER",
                  "score": 0.35,
                  "word": "Ramazotti",
                  "start": 0,
                  "end": 13,
              }
          ],
      )
  
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 12 for calling the TokenClassificationPipelineTests obj's underlying member method code with example usage: obj.test_aggregation_strategy_example2() without return types