class_docstr: Named Entity Recognition pipeline using any `ModelForTokenClassification`. See the [named entity recognition
  examples](../task_summary#named-entity-recognition) for more information.
  
  This token recognition pipeline can currently be loaded from [`pipeline`] using the following task identifier:
  `"ner"` (for predicting the classes of tokens in a sequence: person, organisation, location or miscellaneous).
  
  The models that this pipeline can use are models that have been fine-tuned on a token classification task. See the
  up-to-date list of available models on
  [huggingface.co/models](https://huggingface.co/models?filter=token-classification).
class_docstr_tok: ["Named","Entity","Recognition","pipeline","using","any","`","ModelForTokenClassification","`",".","See","the","[","named","entity","recognition","examples","]","(","..","\/task_summary","#","named-entity-recognition",")","for","more","information",".","This","token","recognition","pipeline","can","currently","be","loaded","from","[","`","pipeline","`","]","using","the","following","task","identifier",":","`","``","ner","''","`","(","for","predicting","the","classes","of","tokens","in","a","sequence",":","person",",","organisation",",","location","or","miscellaneous",")",".","The","models","that","this","pipeline","can","use","are","models","that","have","been","fine-tuned","on","a","token","classification","task",".","See","the","up-to-date","list","of","available","models","on","[","huggingface.co\/models","]","(","https",":","\/\/huggingface.co\/models","?","filter=token-classification",")","."]
docstr: Override tokens from a given word that disagree to force agreement on word boundaries.
  
  Example: micro|soft| com|pany| B-ENT I-NAME I-ENT I-ENT will be rewritten with first strategy as microsoft|
  company| B-ENT I-ENT
docstr_tok: ["Override","tokens","from","a","given","word","that","disagree","to","force","agreement","on","word","boundaries",".","Example",":","micro|soft|","com|pany|","B-ENT","I-NAME","I-ENT","I-ENT","will","be","rewritten","with","first","strategy","as","microsoft|","company|","B-ENT","I-ENT"]
code: def aggregate_words(
      self,
      entities: List[dict],
      aggregation_strategy: AggregationStrategy,
  ) -> List[dict]:
      """
      Override tokens from a given word that disagree to force agreement on word boundaries.
  
      Example: micro|soft| com|pany| B-ENT I-NAME I-ENT I-ENT will be rewritten with first strategy as microsoft|
      company| B-ENT I-ENT
      """
      if aggregation_strategy in {
          AggregationStrategy.NONE,
          AggregationStrategy.SIMPLE,
      }:
          raise ValueError(
              "NONE and SIMPLE strategies are invalid for word aggregation"
          )
  
      word_entities = []
      word_group = None
      for entity in entities:
          if word_group is None:
              word_group = [entity]
          elif entity["is_subword"]:
              word_group.append(entity)
          else:
              word_entities.append(
                  self.aggregate_word(word_group, aggregation_strategy)
              )
              word_group = [entity]
      # Last item
      word_entities.append(
          self.aggregate_word(word_group, aggregation_strategy)
      )
      return word_entities
  
imports: import types
  import warnings
  from typing import List, Optional, Tuple, Union
  import numpy
  from ..models.bert.tokenization_bert import BasicTokenizer
  from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available
  from .base import PIPELINE_INIT_ARGS, ArgumentHandler, Dataset, Pipeline
label_desc: Use image node_id 10 for calling the TokenClassificationPipeline obj's underlying member method code with example usage: obj.aggregate_words(entities, aggregation_strategy) and returns: word_entities