docstr: Test that the correct optimizers are built for a multistage training process
docstr_tok: ["Test","that","the","correct","optimizers","are","built","for","a","multistage","training","process"]
code: def test_multistage_optimizer(self, wordvec_pretrain_file):
      """
      Test that the correct optimizers are built for a multistage training process
      """
      with tempfile.TemporaryDirectory(
          dir=TEST_WORKING_DIR
      ) as tmpdirname:
          extra_args = ["--optim", "adamw"]
          self.run_multistage_tests(
              wordvec_pretrain_file,
              tmpdirname,
              use_lattn=False,
              extra_args=extra_args,
          )
  
          # check that the optimizers which get rebuilt when loading
          # the models are adadelta for the first half of the
          # multistage, then adamw
          each_name = os.path.join(tmpdirname, "each_%02d.pt")
          for i in range(1, 3):
              model_name = each_name % i
              tr = trainer.Trainer.load(model_name, load_optimizer=True)
              assert tr.epochs_trained == i
              assert isinstance(tr.optimizer, optim.Adadelta)
              # double check that this is actually a valid test
              assert not isinstance(tr.optimizer, optim.AdamW)
  
          for i in range(4, 8):
              model_name = each_name % i
              tr = trainer.Trainer.load(model_name, load_optimizer=True)
              assert tr.epochs_trained == i
              assert isinstance(tr.optimizer, optim.AdamW)
  
imports: from collections import defaultdict
  import logging
  import pathlib
  import tempfile
  import pytest
  import torch
  from torch import optim
  from stanza import Pipeline
  from stanza.models import constituency_parser
  from stanza.models.common import pretrain
  from stanza.models.common.bert_embedding import load_bert, load_tokenizer
  from stanza.models.common.foundation_cache import FoundationCache
  from stanza.models.common.utils import set_random_seed
  from stanza.models.constituency import lstm_model
  from stanza.models.constituency import trainer
  from stanza.models.constituency import tree_reader
  from stanza.tests import *
label_desc: Use image node_id 16 for calling the TestTrainer obj's underlying member method code with example usage: obj.test_multistage_optimizer(wordvec_pretrain_file) without return types