class_docstr: A trainer for training models. 
docstr: Train a MWT expander given training word-expansion pairs. 
docstr_tok: ["Train","a","MWT","expander","given","training","word-expansion","pairs","."]
code: def train_dict(self, pairs):
      """Train a MWT expander given training word-expansion pairs."""
      # accumulate counter
      ctr = Counter()
      ctr.update([(p[0], p[1]) for p in pairs])
      seen = set()
      # find the most frequent mappings
      for p, _ in ctr.most_common():
          w, l = p
          if w not in seen and w != l:
              self.expansion_dict[w] = l
          seen.add(w)
      return
  
imports: import sys
  import numpy
  from collections import Counter
  import logging
  import torch
  from torch import nn
  import torch.nn.init
  import stanza.models.common.seq2seq_constant
  from stanza.models.common.trainer import Trainer
  from stanza.models.common.seq2seq_model import Seq2SeqModel
  from stanza.models.common import utils, loss
  from stanza.models.mwt.vocab import Vocab
label_desc: Use image node_id 4 for calling the Trainer obj's underlying member method code with example usage: obj.train_dict(pairs) without return types