class_docstr: A ``WikiTablesErmSemanticParser`` is a :class:`WikiTablesSemanticParser` that learns to search
  for logical forms that yield the correct denotations.
  
  Parameters
  ----------
  vocab : ``Vocabulary``
  question_embedder : ``TextFieldEmbedder``
      Embedder for questions. Passed to super class.
  action_embedding_dim : ``int``
      Dimension to use for action embeddings. Passed to super class.
  encoder : ``Seq2SeqEncoder``
      The encoder to use for the input question. Passed to super class.
  entity_encoder : ``Seq2VecEncoder``
      The encoder to used for averaging the words of an entity. Passed to super class.
  attention : ``Attention``
      We compute an attention over the input question at each step of the decoder, using the
      decoder hidden state as the query.  Passed to WikiTablesDecoderStep.
  decoder_beam_size : ``int``
      Beam size to be used by the ExpectedRiskMinimization algorithm.
  decoder_num_finished_states : ``int``
      Number of finished states for which costs will be computed by the ExpectedRiskMinimization
      algorithm.
  max_decoding_steps : ``int``
      Maximum number of steps the decoder should take before giving up. Used both during training
      and evaluation. Passed to super class.
  normalize_beam_score_by_length : ``bool``, optional (default=False)
      Should we normalize the log-probabilities by length before renormalizing the beam? This was
      shown to work better for NML by Edunov et al., but that many not be the case for semantic
      parsing.
  checklist_cost_weight : ``float``, optional (default=0.6)
      Mixture weight (0-1) for combining coverage cost and denotation cost. As this increases, we
      weigh the coverage cost higher, with a value of 1.0 meaning that we do not care about
      denotation accuracy.
  use_neighbor_similarity_for_linking : ``bool``, optional (default=False)
      If ``True``, we will compute a max similarity between a question token and the `neighbors`
      of an entity as a component of the linking scores.  This is meant to capture the same kind
      of information as the ``related_column`` feature. Passed to super class.
  dropout : ``float``, optional (default=0)
      If greater than 0, we will apply dropout with this probability after all encoders (pytorch
      LSTMs do not apply dropout to their last layer). Passed to super class.
  num_linking_features : ``int``, optional (default=10)
      We need to construct a parameter vector for the linking features, so we need to know how
      many there are.  The default of 10 here matches the default in the ``KnowledgeGraphField``,
      which is to use all ten defined features. If this is 0, another term will be added to the
      linking score. This term contains the maximum similarity value from the entity's neighbors
      and the question. Passed to super class.
  rule_namespace : ``str``, optional (default=rule_labels)
      The vocabulary namespace to use for production rules.  The default corresponds to the
      default used in the dataset reader, so you likely don't need to modify this. Passed to super
      class.
  tables_directory : ``str``, optional (default=/wikitables/)
      The directory to find tables when evaluating logical forms.  We rely on a call to SEMPRE to
      evaluate logical forms, and SEMPRE needs to read the table from disk itself.  This tells
      SEMPRE where to find the tables. Passed to super class.
  mml_model_file : ``str``, optional (default=None)
      If you want to initialize this model using weights from another model trained using MML,
      pass the path to the ``model.tar.gz`` file of that model here.
class_docstr_tok: ["A","``","WikiTablesErmSemanticParser","``","is","a",":","class",":","`","WikiTablesSemanticParser","`","that","learns","to","search","for","logical","forms","that","yield","the","correct","denotations",".","Parameters","--","--","--","--","--","vocab",":","``","Vocabulary","``","question_embedder",":","``","TextFieldEmbedder","``","Embedder","for","questions",".","Passed","to","super","class",".","action_embedding_dim",":","``","int","``","Dimension","to","use","for","action","embeddings",".","Passed","to","super","class",".","encoder",":","``","Seq2SeqEncoder","``","The","encoder","to","use","for","the","input","question",".","Passed","to","super","class",".","entity_encoder",":","``","Seq2VecEncoder","``","The","encoder","to","used","for","averaging","the","words","of","an","entity",".","Passed","to","super","class",".","attention",":","``","Attention","``","We","compute","an","attention","over","the","input","question","at","each","step","of","the","decoder",",","using","the","decoder","hidden","state","as","the","query",".","Passed","to","WikiTablesDecoderStep",".","decoder_beam_size",":","``","int","``","Beam","size","to","be","used","by","the","ExpectedRiskMinimization","algorithm",".","decoder_num_finished_states",":","``","int","``","Number","of","finished","states","for","which","costs","will","be","computed","by","the","ExpectedRiskMinimization","algorithm",".","max_decoding_steps",":","``","int","``","Maximum","number","of","steps","the","decoder","should","take","before","giving","up",".","Used","both","during","training","and","evaluation",".","Passed","to","super","class",".","normalize_beam_score_by_length",":","``","bool","``",",","optional","(","default=False",")","Should","we","normalize","the","log-probabilities","by","length","before","renormalizing","the","beam","?","This","was","shown","to","work","better","for","NML","by","Edunov","et","al.",",","but","that","many","not","be","the","case","for","semantic","parsing",".","checklist_cost_weight",":","``","float","``",",","optional","(","default=0.6",")","Mixture","weight","(","0-1",")","for","combining","coverage","cost","and","denotation","cost",".","As","this","increases",",","we","weigh","the","coverage","cost","higher",",","with","a","value","of","1.0","meaning","that","we","do","not","care","about","denotation","accuracy",".","use_neighbor_similarity_for_linking",":","``","bool","``",",","optional","(","default=False",")","If","``","True","``",",","we","will","compute","a","max","similarity","between","a","question","token","and","the","`","neighbors","`","of","an","entity","as","a","component","of","the","linking","scores",".","This","is","meant","to","capture","the","same","kind","of","information","as","the","``","related_column","``","feature",".","Passed","to","super","class",".","dropout",":","``","float","``",",","optional","(","default=0",")","If","greater","than","0",",","we","will","apply","dropout","with","this","probability","after","all","encoders","(","pytorch","LSTMs","do","not","apply","dropout","to","their","last","layer",")",".","Passed","to","super","class",".","num_linking_features",":","``","int","``",",","optional","(","default=10",")","We","need","to","construct","a","parameter","vector","for","the","linking","features",",","so","we","need","to","know","how","many","there","are",".","The","default","of","10","here","matches","the","default","in","the","``","KnowledgeGraphField","``",",","which","is","to","use","all","ten","defined","features",".","If","this","is","0",",","another","term","will","be","added","to","the","linking","score",".","This","term","contains","the","maximum","similarity","value","from","the","entity","'s","neighbors","and","the","question",".","Passed","to","super","class",".","rule_namespace",":","``","str","``",",","optional","(","default=rule_labels",")","The","vocabulary","namespace","to","use","for","production","rules",".","The","default","corresponds","to","the","default","used","in","the","dataset","reader",",","so","you","likely","do","n't","need","to","modify","this",".","Passed","to","super","class",".","tables_directory",":","``","str","``",",","optional","(","default=\/wikitables\/",")","The","directory","to","find","tables","when","evaluating","logical","forms",".","We","rely","on","a","call","to","SEMPRE","to","evaluate","logical","forms",",","and","SEMPRE","needs","to","read","the","table","from","disk","itself",".","This","tells","SEMPRE","where","to","find","the","tables",".","Passed","to","super","class",".","mml_model_file",":","``","str","``",",","optional","(","default=None",")","If","you","want","to","initialize","this","model","using","weights","from","another","model","trained","using","MML",",","pass","the","path","to","the","``","model.tar.gz","``","file","of","that","model","here","."]
code: def _initialize_weights_from_archive(self, archive):
      logger.info("Initializing weights from MML model.")
      model_parameters = dict(self.named_parameters())
      archived_parameters = dict(archive.model.named_parameters())
      question_embedder_weight = (
          "_question_embedder.token_embedder_tokens.weight"
      )
      if (
          question_embedder_weight not in archived_parameters
          or question_embedder_weight not in model_parameters
      ):
          raise RuntimeError(
              "When initializing model weights from an MML model, we need "
              "the question embedder to be a TokenEmbedder using namespace called "
              "tokens."
          )
      for name, weights in list(archived_parameters.items()):
          if name in model_parameters:
              if name == question_embedder_weight:
                  # The shapes of embedding weights will most likely differ between the two models
                  # because the vocabularies will most likely be different. We will get a mapping
                  # of indices from this model's token indices to the archived model's and copy
                  # the tensor accordingly.
                  vocab_index_mapping = self._get_vocab_index_mapping(
                      archive.model.vocab
                  )
                  archived_embedding_weights = weights.data
                  new_weights = model_parameters[name].data.clone()
                  for index, archived_index in vocab_index_mapping:
                      new_weights[index] = archived_embedding_weights[
                          archived_index
                      ]
                  logger.info(
                      "Copied embeddings of %d out of %d tokens",
                      len(vocab_index_mapping),
                      new_weights.size()[0],
                  )
              else:
                  new_weights = weights.data
              logger.info("Copying parameter %s", name)
              model_parameters[name].data.copy_(new_weights)
  
imports: from __future__ import division
  from __future__ import absolute_import
  import logging
  import os
  import torch
  from allennlp.data import Vocabulary
  from allennlp.data.fields.production_rule_field import ProductionRuleArray
  from allennlp.models.model import Model
  from allennlp.models.archival import load_archive, Archive
  from allennlp.models.semantic_parsing.wikitables.wikitables_decoder_state import WikiTablesDecoderState
  from allennlp.models.semantic_parsing.wikitables.wikitables_decoder_step import WikiTablesDecoderStep
  from allennlp.models.semantic_parsing.wikitables.wikitables_semantic_parser import WikiTablesSemanticParser
  from allennlp.modules import Attention, FeedForward, Seq2SeqEncoder, Seq2VecEncoder, TextFieldEmbedder
  from allennlp.nn.decoding import ChecklistState
  from allennlp.nn.decoding.decoder_trainers import ExpectedRiskMinimization
  from allennlp.semparse import ParsingError
  from allennlp.semparse.type_declarations import wikitables_type_declaration
  from allennlp.semparse.worlds import WikiTablesWorld
  from allennlp.training.metrics import Average
label_desc: Use image node_id 2 for calling the WikiTablesErmSemanticParser obj's underlying member method code with example usage: obj._initialize_weights_from_archive(archive) without return types