docstr: Test that starting a trainer with --relearn_structure copies the old model
docstr_tok: ["Test","that","starting","a","trainer","with","--","relearn_structure","copies","the","old","model"]
code: def test_relearn_structure(self, wordvec_pretrain_file):
      """
      Test that starting a trainer with --relearn_structure copies the old model
      """
  
      with tempfile.TemporaryDirectory(
          dir=TEST_WORKING_DIR
      ) as tmpdirname:
          set_random_seed(1000)
          args = [
              "--pattn_num_layers",
              "0",
              "--lattn_d_proj",
              "0",
              "--hidden_size",
              "20",
              "--delta_embedding_dim",
              "10",
          ]
          tr = build_trainer(wordvec_pretrain_file, *args)
  
          # attempt saving
          filename = os.path.join(tmpdirname, "parser.pt")
          tr.save(filename)
  
          set_random_seed(1001)
          args = [
              "--pattn_num_layers",
              "1",
              "--lattn_d_proj",
              "0",
              "--hidden_size",
              "20",
              "--delta_embedding_dim",
              "10",
              "--relearn_structure",
              "--load_name",
              filename,
          ]
          tr2 = build_trainer(wordvec_pretrain_file, *args)
  
          assert torch.allclose(
              tr.model.delta_embedding.weight,
              tr2.model.delta_embedding.weight,
          )
          assert torch.allclose(
              tr.model.output_layers[0].weight,
              tr2.model.output_layers[0].weight,
          )
          # the norms will be the same, as the non-zero values are all the same
          assert torch.allclose(
              torch.linalg.norm(tr.model.word_lstm.weight_ih_l0),
              torch.linalg.norm(tr2.model.word_lstm.weight_ih_l0),
          )
  
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 6 for calling the TestTrainer obj's underlying member method code with example usage: obj.test_relearn_structure(wordvec_pretrain_file) without return types