def _create_label_data(self, training_data: TrainingData, label_id_dict: Dict[(Text, int)], attribute: Text) -> RasaModelData:
    'Create matrix with label_ids encoded in rows as bag of words.\n\n        Find a training example for each label and get the encoded features\n        from the corresponding Message object.\n        If the features are already computed, fetch them from the message object\n        else compute a one hot encoding for the label as the feature vector.\n        '
    labels_idx_examples = []
    for (label_name, idx) in label_id_dict.items():
        label_example = self._find_example_for_label(label_name, training_data.intent_examples, attribute)
        labels_idx_examples.append((idx, label_example))
    labels_idx_examples = sorted(labels_idx_examples, key=(lambda x: x[0]))
    labels_example = [example for (_, example) in labels_idx_examples]
    if self._check_labels_features_exist(labels_example, attribute):
        (sequence_features, sentence_features) = self._extract_labels_precomputed_features(labels_example, attribute)
    else:
        sequence_features = None
        sentence_features = self._compute_default_label_features(labels_example)
    label_data = RasaModelData()
    label_data.add_features(LABEL, SEQUENCE, sequence_features)
    label_data.add_features(LABEL, SENTENCE, sentence_features)
    if (label_data.does_feature_not_exist(LABEL, SENTENCE) and label_data.does_feature_not_exist(LABEL, SEQUENCE)):
        raise ValueError('No label features are present. Please check your configuration file.')
    label_ids = np.array([idx for (idx, _) in labels_idx_examples])
    label_data.add_features(LABEL_KEY, LABEL_SUB_KEY, [FeatureArray(np.expand_dims(label_ids, (- 1)), number_of_dimensions=2)])
    label_data.add_lengths(LABEL, SEQUENCE_LENGTH, LABEL, SEQUENCE)
    return label_data
Create matrix with label_ids encoded in rows as bag of words.

Find a training example for each label and get the encoded features
from the corresponding Message object.
If the features are already computed, fetch them from the message object
else compute a one hot encoding for the label as the feature vector.
def _create_label_data(self, training_data: TrainingData, label_id_dict: Dict[(Text, int)], attribute: Text) -> RasaModelData:
    'Create matrix with label_ids encoded in rows as bag of words.\n\n        Find a training example for each label and get the encoded features\n        from the corresponding Message object.\n        If the features are already computed, fetch them from the message object\n        else compute a one hot encoding for the label as the feature vector.\n        '
    labels_idx_examples = []
    for (label_name, idx) in label_id_dict.items():
        label_example = self._find_example_for_label(label_name, training_data.intent_examples, attribute)
        labels_idx_examples.append((idx, label_example))
    labels_idx_examples = sorted(labels_idx_examples, key=(lambda x: x[0]))
    labels_example = [example for (_, example) in labels_idx_examples]
    if self._check_labels_features_exist(labels_example, attribute):
        (sequence_features, sentence_features) = self._extract_labels_precomputed_features(labels_example, attribute)
    else:
        sequence_features = None
        sentence_features = self._compute_default_label_features(labels_example)
    label_data = RasaModelData()
    label_data.add_features(LABEL, SEQUENCE, sequence_features)
    label_data.add_features(LABEL, SENTENCE, sentence_features)
    if (label_data.does_feature_not_exist(LABEL, SENTENCE) and label_data.does_feature_not_exist(LABEL, SEQUENCE)):
        raise ValueError('No label features are present. Please check your configuration file.')
    label_ids = np.array([idx for (idx, _) in labels_idx_examples])
    label_data.add_features(LABEL_KEY, LABEL_SUB_KEY, [FeatureArray(np.expand_dims(label_ids, (- 1)), number_of_dimensions=2)])
    label_data.add_lengths(LABEL, SEQUENCE_LENGTH, LABEL, SEQUENCE)
    return label_data