code: def align_token_features(
      list_of_tokens: List[List["Token"]],
      in_token_features: np.ndarray,
      shape: Optional[Tuple] = None,
  ) -> np.ndarray:
      """Align token features to match tokens.
  
      ConveRTFeaturizer and LanguageModelFeaturizer might split up tokens into sub-tokens.
      We need to take the mean of the sub-token vectors and take that as token vector.
  
      Args:
          list_of_tokens: tokens for examples
          in_token_features: token features from ConveRT
          shape: shape of feature matrix
  
      Returns:
          Token features.
      """
      if shape is None:
          shape = in_token_features.shape
      out_token_features = np.zeros(shape)
  
      for example_idx, example_tokens in enumerate(list_of_tokens):
          offset = 0
          for token_idx, token in enumerate(example_tokens):
              number_sub_words = token.get(NUMBER_OF_SUB_TOKENS, 1)
  
              if number_sub_words > 1:
                  token_start_idx = token_idx + offset
                  token_end_idx = token_idx + offset + number_sub_words
  
                  mean_vec = np.mean(
                      in_token_features[example_idx][
                          token_start_idx:token_end_idx
                      ],
                      axis=0,
                  )
  
                  offset += number_sub_words - 1
  
                  out_token_features[example_idx][token_idx] = mean_vec
              else:
                  out_token_features[example_idx][
                      token_idx
                  ] = in_token_features[example_idx][token_idx + offset]
  
      return out_token_features
  
imports: from pathlib import Path
  import numpy
  from typing import Optional, Text, Dict, Any, Union, List, Tuple, TYPE_CHECKING
  import rasa.shared.utils.common
  import rasa.shared.utils.io
  import rasa.nlu.utils.bilou_utils
  from rasa.shared.constants import NEXT_MAJOR_VERSION_FOR_DEPRECATIONS
  from rasa.nlu.constants import NUMBER_OF_SUB_TOKENS
  import rasa.utils.io
  from rasa.utils.tensorflow.constants import LOSS_TYPE, RANKING_LENGTH, RENORMALIZE_CONFIDENCES, SIMILARITY_TYPE, EVAL_NUM_EXAMPLES, EVAL_NUM_EPOCHS, EPOCHS, SOFTMAX, MARGIN, AUTO, INNER, COSINE, SEQUENCE, CROSS_ENTROPY, CONSTRAIN_SIMILARITIES, MODEL_CONFIDENCE, TOLERANCE, CHECKPOINT_MODEL
  from rasa.utils.tensorflow.callback import RasaTrainingLogger, RasaModelCheckpoint
  from rasa.utils.tensorflow.data_generator import RasaBatchDataGenerator
  from rasa.utils.tensorflow.model_data import RasaModelData
  from rasa.shared.nlu.constants import SPLIT_ENTITIES_BY_COMMA
  from rasa.shared.exceptions import InvalidConfigException
label_desc: Use image node_id 3 for calling a global function with example usage: align_token_features(list_of_tokens, in_token_features, shape) and returns: out_token_features