class_docstr: Trains a model using a graph schema.
class_docstr_tok: ["Trains","a","model","using","a","graph","schema","."]
docstr: Trains and packages a model and returns the prediction graph runner.
  
  Args:
      model_configuration: The model configuration (schemas, language, etc.)
      importer: The importer which provides the training data for the training.
      output_filename: The location to save the packaged model.
      force_retraining: If `True` then the cache is skipped and all components
          are retrained.
  
  Returns:
      The metadata describing the trained model.
docstr_tok: ["Trains","and","packages","a","model","and","returns","the","prediction","graph","runner",".","Args",":","model_configuration",":","The","model","configuration","(","schemas",",","language",",","etc",".",")","importer",":","The","importer","which","provides","the","training","data","for","the","training",".","output_filename",":","The","location","to","save","the","packaged","model",".","force_retraining",":","If","`","True","`","then","the","cache","is","skipped","and","all","components","are","retrained",".","Returns",":","The","metadata","describing","the","trained","model","."]
code: def train(
      self,
      model_configuration: GraphModelConfiguration,
      importer: TrainingDataImporter,
      output_filename: Path,
      force_retraining: bool = False,
      is_finetuning: bool = False,
  ) -> ModelMetadata:
      """Trains and packages a model and returns the prediction graph runner.
  
      Args:
          model_configuration: The model configuration (schemas, language, etc.)
          importer: The importer which provides the training data for the training.
          output_filename: The location to save the packaged model.
          force_retraining: If `True` then the cache is skipped and all components
              are retrained.
  
      Returns:
          The metadata describing the trained model.
      """
      logger.debug("Starting training.")
  
      # Retrieve the domain for the model metadata right at the start.
      # This avoids that something during the graph runs mutates it.
      domain = copy.deepcopy(importer.get_domain())
  
      if force_retraining:
          logger.debug(
              "Skip fingerprint run as a full training of the model was enforced."
          )
          pruned_training_schema = model_configuration.train_schema
      else:
          fingerprint_run_outputs = self.fingerprint(
              model_configuration.train_schema,
              importer=importer,
              is_finetuning=is_finetuning,
          )
          pruned_training_schema = self._prune_schema(
              model_configuration.train_schema, fingerprint_run_outputs
          )
  
      hooks = [
          LoggingHook(pruned_schema=pruned_training_schema),
          TrainingHook(
              cache=self._cache,
              model_storage=self._model_storage,
              pruned_schema=pruned_training_schema,
          ),
      ]
  
      graph_runner = self._graph_runner_class.create(
          graph_schema=pruned_training_schema,
          model_storage=self._model_storage,
          execution_context=ExecutionContext(
              graph_schema=model_configuration.train_schema,
              is_finetuning=is_finetuning,
          ),
          hooks=hooks,
      )
  
      logger.debug(
          "Running the pruned train graph with real node execution."
      )
  
      graph_runner.run(inputs={PLACEHOLDER_IMPORTER: importer})
  
      return self._model_storage.create_model_package(
          output_filename, model_configuration, domain
      )
  
file_path: rasa/rasa/engine/training/graph_trainer.py
imports: import copy
  import logging
  from pathlib import Path
  from typing import Any, Dict, Text, Type, Union
  from rasa.engine.caching import TrainingCache
  from rasa.engine.graph import ExecutionContext, GraphSchema, GraphModelConfiguration
  from rasa.engine.constants import PLACEHOLDER_IMPORTER
  from rasa.engine.runner.interface import GraphRunner
  from rasa.engine.storage.storage import ModelStorage, ModelMetadata
  from rasa.engine.training.components import PrecomputedValueProvider, FingerprintComponent, FingerprintStatus
  from rasa.engine.training.hooks import TrainingHook, LoggingHook
  from rasa.shared.importers.importer import TrainingDataImporter
label_desc: Use image node_id 2 for calling the GraphTrainer obj's underlying member method code with example usage: obj.train(model_configuration, importer, output_filename, force_retraining, is_finetuning) and returns: self