code: def test_aggregation_strategy(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 = [
          {
              "scores": np.array(
                  [0, 0, 0, 0, 0.9968166351318359, 0, 0, 0]
              ),  # fmt : skip
              "index": 1,
              "is_subword": False,
              "word": "En",
              "start": 0,
              "end": 2,
          },
          {
              "scores": np.array(
                  [0, 0, 0, 0, 0.9957635998725891, 0, 0, 0]
              ),  # fmt : skip
              "index": 2,
              "is_subword": True,
              "word": "##zo",
              "start": 2,
              "end": 4,
          },
          {
              "scores": np.array(
                  [0, 0, 0, 0, 0, 0.9986497163772583, 0, 0]
              ),  # fmt : skip
              "index": 7,
              "word": "UN",
              "is_subword": False,
              "start": 11,
              "end": 13,
          },
      ]
      self.assertEqual(
          nested_simplify(
              token_classifier.aggregate(
                  example, AggregationStrategy.NONE
              )
          ),
          [
              {
                  "end": 2,
                  "entity": "I-PER",
                  "score": 0.997,
                  "start": 0,
                  "word": "En",
                  "index": 1,
              },
              {
                  "end": 4,
                  "entity": "I-PER",
                  "score": 0.996,
                  "start": 2,
                  "word": "##zo",
                  "index": 2,
              },
              {
                  "end": 13,
                  "entity": "B-ORG",
                  "score": 0.999,
                  "start": 11,
                  "word": "UN",
                  "index": 7,
              },
          ],
      )
      self.assertEqual(
          nested_simplify(
              token_classifier.aggregate(
                  example, AggregationStrategy.SIMPLE
              )
          ),
          [
              {
                  "entity_group": "PER",
                  "score": 0.996,
                  "word": "Enzo",
                  "start": 0,
                  "end": 4,
              },
              {
                  "entity_group": "ORG",
                  "score": 0.999,
                  "word": "UN",
                  "start": 11,
                  "end": 13,
              },
          ],
      )
      self.assertEqual(
          nested_simplify(
              token_classifier.aggregate(
                  example, AggregationStrategy.FIRST
              )
          ),
          [
              {
                  "entity_group": "PER",
                  "score": 0.997,
                  "word": "Enzo",
                  "start": 0,
                  "end": 4,
              },
              {
                  "entity_group": "ORG",
                  "score": 0.999,
                  "word": "UN",
                  "start": 11,
                  "end": 13,
              },
          ],
      )
      self.assertEqual(
          nested_simplify(
              token_classifier.aggregate(
                  example, AggregationStrategy.MAX
              )
          ),
          [
              {
                  "entity_group": "PER",
                  "score": 0.997,
                  "word": "Enzo",
                  "start": 0,
                  "end": 4,
              },
              {
                  "entity_group": "ORG",
                  "score": 0.999,
                  "word": "UN",
                  "start": 11,
                  "end": 13,
              },
          ],
      )
      self.assertEqual(
          nested_simplify(
              token_classifier.aggregate(
                  example, AggregationStrategy.AVERAGE
              )
          ),
          [
              {
                  "entity_group": "PER",
                  "score": 0.996,
                  "word": "Enzo",
                  "start": 0,
                  "end": 4,
              },
              {
                  "entity_group": "ORG",
                  "score": 0.999,
                  "word": "UN",
                  "start": 11,
                  "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 11 for calling the TokenClassificationPipelineTests obj's underlying member method code with example usage: obj.test_aggregation_strategy() without return types