docstr: Copy parameters from the other model to this model
  
  word_lstm can change size if the other model didn't use pattn / lattn and this one does.
  In that case, the new values are initialized to 0.
  This will rebuild the model in such a way that the outputs will be
  exactly the same as the previous model.
code: def copy_with_new_structure(self, other):
      """
      Copy parameters from the other model to this model
  
      word_lstm can change size if the other model didn't use pattn / lattn and this one does.
      In that case, the new values are initialized to 0.
      This will rebuild the model in such a way that the outputs will be
      exactly the same as the previous model.
      """
      if (
          self.constituency_composition
          != other.constituency_composition
          and self.constituency_composition
          != ConstituencyComposition.UNTIED_MAX
      ):
          raise ValueError(
              "Models are incompatible: self.constituency_composition == {}, other.constituency_composition == {}".format(
                  self.constituency_composition,
                  other.constituency_composition,
              )
          )
      for name, other_parameter in other.named_parameters():
          # this allows other.constituency_composition == UNTIED_MAX to fall through
          if (
              name.startswith("reduce_linear.")
              and self.constituency_composition
              == ConstituencyComposition.UNTIED_MAX
          ):
              if name == "reduce_linear.weight":
                  my_parameter = self.reduce_linear_weight
              elif name == "reduce_linear.bias":
                  my_parameter = self.reduce_linear_bias
              else:
                  raise ValueError(
                      "Unexpected other parameter name {}".format(name)
                  )
              for idx in range(len(self.constituent_opens)):
                  my_parameter[idx].data.copy_(other_parameter.data)
          elif name.startswith("word_lstm.weight_ih_l0"):
              # bottom layer shape may have changed from adding a new pattn / lattn block
              my_parameter = self.get_parameter(name)
              # -1 so that it can be converted easier to a different parameter
              copy_size = min(
                  other_parameter.data.shape[-1],
                  my_parameter.data.shape[-1],
              )
              # new_values = my_parameter.data.clone().detach()
              new_values = torch.zeros_like(my_parameter.data)
              new_values[..., :copy_size] = other_parameter.data[
                  ..., :copy_size
              ]
              my_parameter.data.copy_(new_values)
          else:
              self.get_parameter(name).data.copy_(other_parameter.data)
  
imports: from collections import namedtuple
  from enum import Enum
  import logging
  import math
  import random
  import torch
  import torch.nn
  from torch.nn.utils.rnn import pack_padded_sequence
  from stanza.models.common.bert_embedding import extract_bert_embeddings
  from stanza.models.common.maxout_linear import MaxoutLinear
  from stanza.models.common.utils import unsort
  from stanza.models.common.vocab import PAD_ID, UNK_ID
  from stanza.models.constituency.base_model import BaseModel
  from stanza.models.constituency.label_attention import LabelAttentionModule
  from stanza.models.constituency.lstm_tree_stack import LSTMTreeStack
  from stanza.models.constituency.parse_transitions import TransitionScheme
  from stanza.models.constituency.parse_tree import Tree
  from stanza.models.constituency.partitioned_transformer import PartitionedTransformerModule
  from stanza.models.constituency.positional_encoding import ConcatSinusoidalEncoding
  from stanza.models.constituency.transformer_tree_stack import TransformerTreeStack
  from stanza.models.constituency.tree_stack import TreeStack
  from stanza.models.constituency.utils import build_nonlinearity, initialize_linear
label_desc: Use image node_id 5 for calling the LSTMModel obj's underlying member method code with example usage: obj.copy_with_new_structure(other) without return types