src/transformers/pipelines/token_classification.py/TokenClassificationPipeline/postprocess
class TokenClassificationPipeline:    def postprocess(self, model_outputs, aggregation_strategy=AggregationStrategy.NONE):
        outputs = model_outputs["outputs"]
        sentence = model_outputs["sentence"]
        input_ids = model_outputs["input_ids"][0]
        offset_mapping = model_outputs["offset_mapping"][0] if model_outputs["offset_mapping"] is not None else None
        special_tokens_mask = model_outputs["special_tokens_mask"][0].numpy()

        scores = np.exp(outputs) / np.exp(outputs).sum(-1, keepdims=True)
        pre_entities = self.gather_pre_entities(
            sentence, input_ids, scores, offset_mapping, special_tokens_mask, aggregation_strategy
        )
        grouped_entities = self.aggregate(pre_entities, aggregation_strategy)
        # Filter anything that is in self.ignore_labels
        entities = [
            entity
            for entity in grouped_entities
            if entity.get("entity", None) not in self.ignore_labels
            and entity.get("entity_group", None) not in self.ignore_labels
        ]
        return entities