def train(self, training_data: TrainingData) -> Resource:
    'Train the embedding intent classifier on a data set.'
    model_data = self.preprocess_train_data(training_data)
    if model_data.is_empty():
        logger.debug(f"Cannot train '{self.__class__.__name__}'. No data was provided. Skipping training of the classifier.")
        return self._resource
    if ((not self.model) and self.finetune_mode):
        raise rasa.shared.exceptions.InvalidParameterException(f'{self.__class__.__name__} was instantiated with `model=None` and `finetune_mode=True`. This is not a valid combination as the component needs an already instantiated and trained model to continue training in finetune mode.')
    if self.component_config.get(INTENT_CLASSIFICATION):
        if (not self._check_enough_labels(model_data)):
            logger.error(f"Cannot train '{self.__class__.__name__}'. Need at least 2 different intent classes. Skipping training of classifier.")
            return self._resource
    if self.component_config.get(ENTITY_RECOGNITION):
        self.check_correct_entity_annotations(training_data)
    self._data_example = model_data.first_data_example()
    if (not self.finetune_mode):
        self.model = self._instantiate_model_class(model_data)
        self.model.compile(optimizer=tf.keras.optimizers.Adam(self.component_config[LEARNING_RATE]))
    else:
        self.model.adjust_for_incremental_training(data_example=self._data_example, new_sparse_feature_sizes=model_data.get_sparse_feature_sizes(), old_sparse_feature_sizes=self._sparse_feature_sizes)
    self._sparse_feature_sizes = model_data.get_sparse_feature_sizes()
    (data_generator, validation_data_generator) = train_utils.create_data_generators(model_data, self.component_config[BATCH_SIZES], self.component_config[EPOCHS], self.component_config[BATCH_STRATEGY], self.component_config[EVAL_NUM_EXAMPLES], self.component_config[RANDOM_SEED])
    callbacks = train_utils.create_common_callbacks(self.component_config[EPOCHS], self.component_config[TENSORBOARD_LOG_DIR], self.component_config[TENSORBOARD_LOG_LEVEL], self.tmp_checkpoint_dir)
    self.model.fit(data_generator, epochs=self.component_config[EPOCHS], validation_data=validation_data_generator, validation_freq=self.component_config[EVAL_NUM_EPOCHS], callbacks=callbacks, verbose=False, shuffle=False)
    self.persist()
    return self._resource
Train the embedding intent classifier on a data set.
def train(self, training_data: TrainingData) -> Resource:
    
    model_data = self.preprocess_train_data(training_data)
    if model_data.is_empty():
        logger.debug(f"Cannot train '{self.__class__.__name__}'. No data was provided. Skipping training of the classifier.")
        return self._resource
    if ((not self.model) and self.finetune_mode):
        raise rasa.shared.exceptions.InvalidParameterException(f'{self.__class__.__name__} was instantiated with `model=None` and `finetune_mode=True`. This is not a valid combination as the component needs an already instantiated and trained model to continue training in finetune mode.')
    if self.component_config.get(INTENT_CLASSIFICATION):
        if (not self._check_enough_labels(model_data)):
            logger.error(f"Cannot train '{self.__class__.__name__}'. Need at least 2 different intent classes. Skipping training of classifier.")
            return self._resource
    if self.component_config.get(ENTITY_RECOGNITION):
        self.check_correct_entity_annotations(training_data)
    self._data_example = model_data.first_data_example()
    if (not self.finetune_mode):
        self.model = self._instantiate_model_class(model_data)
        self.model.compile(optimizer=tf.keras.optimizers.Adam(self.component_config[LEARNING_RATE]))
    else:
        self.model.adjust_for_incremental_training(data_example=self._data_example, new_sparse_feature_sizes=model_data.get_sparse_feature_sizes(), old_sparse_feature_sizes=self._sparse_feature_sizes)
    self._sparse_feature_sizes = model_data.get_sparse_feature_sizes()
    (data_generator, validation_data_generator) = train_utils.create_data_generators(model_data, self.component_config[BATCH_SIZES], self.component_config[EPOCHS], self.component_config[BATCH_STRATEGY], self.component_config[EVAL_NUM_EXAMPLES], self.component_config[RANDOM_SEED])
    callbacks = train_utils.create_common_callbacks(self.component_config[EPOCHS], self.component_config[TENSORBOARD_LOG_DIR], self.component_config[TENSORBOARD_LOG_LEVEL], self.tmp_checkpoint_dir)
    self.model.fit(data_generator, epochs=self.component_config[EPOCHS], validation_data=validation_data_generator, validation_freq=self.component_config[EVAL_NUM_EPOCHS], callbacks=callbacks, verbose=False, shuffle=False)
    self.persist()
    return self._resource