class_docstr: A Mitie Entity Extractor (which is a thin wrapper around `Dlib-ml`).
class_docstr_tok: ["A","Mitie","Entity","Extractor","(","which","is","a","thin","wrapper","around","`","Dlib-ml","`",")","."]
docstr: Trains a MITIE named entity recognizer.
  
  Args:
      training_data: the training data
      model: a MitieModel
  Returns:
      resource for loading the trained model
docstr_tok: ["Trains","a","MITIE","named","entity","recognizer",".","Args",":","training_data",":","the","training","data","model",":","a","MitieModel","Returns",":","resource","for","loading","the","trained","model"]
code: def train(
      self, training_data: TrainingData, model: MitieModel
  ) -> Resource:
      """Trains a MITIE named entity recognizer.
  
      Args:
          training_data: the training data
          model: a MitieModel
      Returns:
          resource for loading the trained model
      """
      import mitie
  
      trainer = mitie.ner_trainer(str(model.model_path))
      trainer.num_threads = self._config["num_threads"]
  
      # check whether there are any (not pre-trained) entities in the training data
      found_one_entity = False
  
      # filter out pre-trained entity examples
      filtered_entity_examples = self.filter_trainable_entities(
          training_data.nlu_examples
      )
  
      for example in filtered_entity_examples:
          sample = self._prepare_mitie_sample(example)
  
          found_one_entity = sample.num_entities > 0 or found_one_entity
          trainer.add(sample)
  
      # Mitie will fail to train if there is not a single entity tagged
      if found_one_entity:
          self._ner = trainer.train()
      else:
          rasa.shared.utils.io.raise_warning(
              f"{self.__class__.__name__} could not be trained because no trainable "
              f"entities where found in the given training data. Please add some "
              f"NLU training examples that include entities where the `extractor` "
              f"is either `None` or '{self.__class__.__name__}'."
          )
  
      self.persist()
      return self._resource
  
imports: from __future__ import annotations
  import logging
  from rasa.nlu.tokenizers.tokenizer import Tokenizer
  import typing
  from typing import Any, Dict, List, Optional, Text, Type
  from rasa.engine.graph import GraphComponent, ExecutionContext
  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.constants import TOKENS_NAMES
  from rasa.shared.nlu.constants import ENTITY_ATTRIBUTE_CONFIDENCE, ENTITY_ATTRIBUTE_START, ENTITY_ATTRIBUTE_END, ENTITY_ATTRIBUTE_TYPE, ENTITY_ATTRIBUTE_VALUE, TEXT, ENTITIES
  from rasa.nlu.utils.mitie_utils import MitieModel, MitieNLP
  from rasa.nlu.extractors.extractor import EntityExtractorMixin
  from rasa.shared.nlu.training_data.training_data import TrainingData
  from rasa.shared.nlu.training_data.message import Message
  import rasa.shared.utils.io
  from rasa.shared.exceptions import InvalidConfigException
label_desc: Use image node_id 7 for calling the MitieEntityExtractor obj's underlying member method code with example usage: obj.train(training_data, model) and returns: self