code: def frozen_transformer_test(
      self, wordvec_pretrain_file, transformer_name
  ):
      with tempfile.TemporaryDirectory(
          dir=TEST_WORKING_DIR
      ) as tmpdirname:
          foundation_cache = FoundationCache()
          args = ["--bert_model", transformer_name]
          args, trained_model = self.run_train_test(
              wordvec_pretrain_file,
              tmpdirname,
              extra_args=args,
              foundation_cache=foundation_cache,
          )
          bert_model, bert_tokenizer = foundation_cache.load_bert(
              transformer_name
          )
          assert self.bert_weights_allclose(bert_model, trained_model)
  
          checkpoint = torch.load(
              args["save_name"], lambda storage, loc: storage
          )
          params = checkpoint["params"]
          # check that the bert model wasn't saved in the model
          assert all(
              not x.startswith("bert_model.")
              for x in params["model"].keys()
          )
          # make sure we're looking at the right thing
          assert any(
              x.startswith("output_layers.")
              for x in params["model"].keys()
          )
  
          # check that the cached model is used as expected when loading a bert model
          trained_model = trainer.Trainer.load(
              args["save_name"], foundation_cache=foundation_cache
          )
          assert trained_model.model.bert_model is bert_model
  
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 20 for calling the TestTrainer obj's underlying member method code with example usage: obj.frozen_transformer_test(wordvec_pretrain_file, transformer_name) without return types