class_docstr: Intent classifier which uses the `mitie` library.
class_docstr_tok: ["Intent","classifier","which","uses","the","`","mitie","`","library","."]
docstr: Trains classifier.
  
  Args:
      training_data: The NLU training data.
      model: The loaded mitie model provided by `MitieNLP`.
  
  Returns:
      The resource locator for the trained classifier.
docstr_tok: ["Trains","classifier",".","Args",":","training_data",":","The","NLU","training","data",".","model",":","The","loaded","mitie","model","provided","by","`","MitieNLP","`",".","Returns",":","The","resource","locator","for","the","trained","classifier","."]
code: def train(
      self, training_data: TrainingData, model: MitieModel
  ) -> Resource:
      """Trains classifier.
  
      Args:
          training_data: The NLU training data.
          model: The loaded mitie model provided by `MitieNLP`.
  
      Returns:
          The resource locator for the trained classifier.
      """
      import mitie
  
      trainer = mitie.text_categorizer_trainer(str(model.model_path))
      trainer.num_threads = self._config["num_threads"]
  
      for example in training_data.intent_examples:
          tokens = self._tokens_of_message(example)
          trainer.add_labeled_text(tokens, example.get(INTENT))
  
      if training_data.intent_examples:
          # we can not call train if there are no examples!
          clf = trainer.train()
          self._persist(clf)
  
      return self._resource
  
imports: from __future__ import annotations
  import logging
  from rasa.nlu.featurizers.featurizer import Featurizer
  import typing
  from typing import Any, Dict, List, Optional, Text, Type
  from rasa.engine.graph import ExecutionContext, GraphComponent
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
  from rasa.engine.storage.resource import Resource
  from rasa.engine.storage.storage import ModelStorage
  from rasa.nlu.classifiers.classifier import IntentClassifier
  from rasa.nlu.utils.mitie_utils import MitieModel, MitieNLP
  from rasa.nlu.constants import TOKENS_NAMES
  from rasa.shared.nlu.constants import TEXT, INTENT
  from rasa.shared.nlu.training_data.training_data import TrainingData
  from rasa.shared.nlu.training_data.message import Message
label_desc: Use image node_id 5 for calling the MitieIntentClassifier obj's underlying member method code with example usage: obj.train(training_data, model) and returns: self