docstr: Sets the features on a single message. Utility method.
docstr_tok: ["Sets","the","features","on","a","single","message",".","Utility","method","."]
code: def _set_features(
      self, message: Message, attribute: Text = TEXT
  ) -> None:
      """Sets the features on a single message. Utility method."""
      tokens = message.get(TEXT_TOKENS)
  
      # If the message doesn't have tokens, we can't create features.
      if not tokens:
          return None
  
      # We need to reshape here such that the shape is equivalent to that of sparsely
      # generated features. Without it, it'd be a 1D tensor. We need 2D (n_utterance, n_dim).
      text_vector = self._create_word_vector(
          document=message.get(TEXT)
      ).reshape(1, -1)
      word_vectors = np.array(
          [self._create_word_vector(document=t.text) for t in tokens]
      )
  
      final_sequence_features = Features(
          word_vectors,
          FEATURE_TYPE_SEQUENCE,
          attribute,
          self._config[FEATURIZER_CLASS_ALIAS],
      )
      message.add_features(final_sequence_features)
      final_sentence_features = Features(
          text_vector,
          FEATURE_TYPE_SENTENCE,
          attribute,
          self._config[FEATURIZER_CLASS_ALIAS],
      )
      message.add_features(final_sentence_features)
  
imports: import numpy
  import logging
  from bpemb import BPEmb
  from typing import Any, Text, Dict, List, Type
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
  from rasa.engine.graph import ExecutionContext, GraphComponent
  from rasa.engine.storage.resource import Resource
  from rasa.engine.storage.storage import ModelStorage
  from rasa.nlu.featurizers.dense_featurizer.dense_featurizer import DenseFeaturizer
  from rasa.nlu.tokenizers.tokenizer import Tokenizer
  from rasa.shared.nlu.training_data.training_data import TrainingData
  from rasa.shared.nlu.training_data.features import Features
  from rasa.shared.nlu.training_data.message import Message
  from rasa.nlu.constants import DENSE_FEATURIZABLE_ATTRIBUTES, FEATURIZER_CLASS_ALIAS
  from rasa.shared.nlu.constants import TEXT, TEXT_TOKENS, FEATURE_TYPE_SENTENCE, FEATURE_TYPE_SEQUENCE
label_desc: Use image node_id 9 for calling the BytePairFeaturizer obj's underlying member method code with example usage: obj._set_features(message, attribute) and returns: None