code: def group_sub_entities(entities) -> dict:
      """
      Returns grouped sub entities
      """
      # Get the first entity in the entity group
      entity = entities[0]["entity"]
      scores = np.mean([entity["score"] for entity in entities])
      tokens = [entity["word"] for entity in entities]
  
      entity_group = {
          "entity": entity,
          "score": np.mean(scores),
          "word": convert_tokens_to_string(tokens),
      }
      return entity_group
  
imports: import os
  import logging
  import torch
  import numpy
  from .data_ner import BertNERDataBunch
  from torch import nn
  from seqeval.metrics import f1_score, precision_score, recall_score
  from typing import Dict, List, Optional, Tuple
  from .learner_util import Learner
  from transformers import AutoConfig, AutoModelForTokenClassification, Trainer, TrainingArguments, EvalPrediction, HfArgumentParser
label_desc: Use image node_id 2 for calling a global function with example usage: group_sub_entities(entities) and returns: entity_group