docstr: Run the training for a few iterations, load & return the model
docstr_tok: ["Run","the","training","for","a","few","iterations",",","load","&","return","the","model"]
code: def run_training(
      self, tmp_path, train_text, dev_text, extra_args=None
  ):
      """
      Run the training for a few iterations, load & return the model
      """
      pred_file = str(tmp_path / "pred.conllu")
  
      save_name = "test_tagger.pt"
      save_file = str(tmp_path / save_name)
  
      train_file = str(tmp_path / "train.conllu")
      with open(train_file, "w", encoding="utf-8") as fout:
          fout.write(train_text)
  
      dev_file = str(tmp_path / "dev.conllu")
      with open(dev_file, "w", encoding="utf-8") as fout:
          fout.write(dev_text)
  
      args = [
          "--train_file",
          train_file,
          "--eval_file",
          dev_file,
          "--gold_file",
          dev_file,
          "--output_file",
          pred_file,
          "--num_epoch",
          "2",
          "--log_step",
          "10",
          "--save_dir",
          str(tmp_path),
          "--save_name",
          save_name,
          "--shorthand",
          "en_test",
      ]
      if extra_args is not None:
          args = args + extra_args
      lemmatizer.main(args)
  
      assert os.path.exists(save_file)
      saved_model = trainer.Trainer(model_file=save_file)
      return saved_model
  
file_path: stanza/stanza/tests/lemma/test_lemma_trainer.py
imports: import pytest
  import glob
  import os
  import tempfile
  import torch
  from stanza.models import lemmatizer
  from stanza.models.lemma import trainer
  from stanza.tests import *
  from stanza.utils.training.common import choose_lemma_charlm, build_charlm_args
label_desc: Use image node_id 2 for calling the TestLemmatizer obj's underlying member method code with example usage: obj.run_training(tmp_path, train_text, dev_text, extra_args) and returns: saved_model