class_docstr: Dictionary encapsulates the mapping between normalized words and their integer ids.
  
  Notable instance attributes:
  
  Attributes
  ----------
  token2id : dict of (str, int)
      token -> token_id. I.e. the reverse mapping to `self[token_id]`.
  cfs : dict of (int, int)
      Collection frequencies: token_id -> how many instances of this token are contained in the documents.
  dfs : dict of (int, int)
      Document frequencies: token_id -> how many documents contain this token.
  num_docs : int
      Number of documents processed.
  num_pos : int
      Total number of corpus positions (number of processed words).
  num_nnz : int
      Total number of non-zeroes in the BOW matrix (sum of the number of unique
      words per document over the entire corpus).
class_docstr_tok: ["Dictionary","encapsulates","the","mapping","between","normalized","words","and","their","integer","ids",".","Notable","instance","attributes",":","Attributes","--","--","--","--","--","token2id",":","dict","of","(","str",",","int",")","token","-",">","token_id",".","I.e",".","the","reverse","mapping","to","`","self","[","token_id","]","`",".","cfs",":","dict","of","(","int",",","int",")","Collection","frequencies",":","token_id","-",">","how","many","instances","of","this","token","are","contained","in","the","documents",".","dfs",":","dict","of","(","int",",","int",")","Document","frequencies",":","token_id","-",">","how","many","documents","contain","this","token",".","num_docs",":","int","Number","of","documents","processed",".","num_pos",":","int","Total","number","of","corpus","positions","(","number","of","processed","words",")",".","num_nnz",":","int","Total","number","of","non-zeroes","in","the","BOW","matrix","(","sum","of","the","number","of","unique","words","per","document","over","the","entire","corpus",")","."]
docstr: Merge another dictionary into this dictionary, mapping the same tokens to the same ids
  and new tokens to new ids.
  
  Notes
  -----
  The purpose is to merge two corpora created using two different dictionaries: `self` and `other`.
  `other` can be any id=>word mapping (a dict, a Dictionary object, ...).
  
  Return a transformation object which, when accessed as `result[doc_from_other_corpus]`, will convert documents
  from a corpus built using the `other` dictionary into a document using the new, merged dictionary.
  
  Parameters
  ----------
  other : {dict, :class:`~gensim.corpora.dictionary.Dictionary`}
      Other dictionary.
  
  Return
  ------
  :class:`gensim.models.VocabTransform`
      Transformation object.
  
  Examples
  --------
  .. sourcecode:: pycon
  
      >>> from gensim.corpora import Dictionary
      >>>
      >>> corpus_1, corpus_2 = [["a", "b", "c"]], [["a", "f", "f"]]
      >>> dct_1, dct_2 = Dictionary(corpus_1), Dictionary(corpus_2)
      >>> dct_1.doc2bow(corpus_2[0])
      [(0, 1)]
      >>> transformer = dct_1.merge_with(dct_2)
      >>> dct_1.doc2bow(corpus_2[0])
      [(0, 1), (3, 2)]
docstr_tok: ["Merge","another","dictionary","into","this","dictionary",",","mapping","the","same","tokens","to","the","same","ids","and","new","tokens","to","new","ids",".","Notes","--","--","-","The","purpose","is","to","merge","two","corpora","created","using","two","different","dictionaries",":","`","self","`","and","`","other","`",".","`","other","`","can","be","any","id=",">","word","mapping","(","a","dict",",","a","Dictionary","object",",","...",")",".","Return","a","transformation","object","which",",","when","accessed","as","`","result","[","doc_from_other_corpus","]","`",",","will","convert","documents","from","a","corpus","built","using","the","`","other","`","dictionary","into","a","document","using","the","new",",","merged","dictionary",".","Parameters","--","--","--","--","--","other",":","{","dict",",",":","class",":","`","~gensim.corpora.dictionary.Dictionary","`","}","Other","dictionary",".","Return","--","--","--",":","class",":","`","gensim.models.VocabTransform","`","Transformation","object",".","Examples","--","--","--","--","..","sourcecode",":",":","pycon",">",">",">","from","gensim.corpora","import","Dictionary",">",">",">",">",">",">","corpus_1",",","corpus_2","=","[","[","``","a","''",",","``","b","''",",","``","c","''","]","]",",","[","[","``","a","''",",","``","f","''",",","``","f","''","]","]",">",">",">","dct_1",",","dct_2","=","Dictionary","(","corpus_1",")",",","Dictionary","(","corpus_2",")",">",">",">","dct_1.doc2bow","(","corpus_2","[","0","]",")","[","(","0",",","1",")","]",">",">",">","transformer","=","dct_1.merge_with","(","dct_2",")",">",">",">","dct_1.doc2bow","(","corpus_2","[","0","]",")","[","(","0",",","1",")",",","(","3",",","2",")","]"]
code: def merge_with(self, other):
      """Merge another dictionary into this dictionary, mapping the same tokens to the same ids
      and new tokens to new ids.
  
      Notes
      -----
      The purpose is to merge two corpora created using two different dictionaries: `self` and `other`.
      `other` can be any id=>word mapping (a dict, a Dictionary object, ...).
  
      Return a transformation object which, when accessed as `result[doc_from_other_corpus]`, will convert documents
      from a corpus built using the `other` dictionary into a document using the new, merged dictionary.
  
      Parameters
      ----------
      other : {dict, :class:`~gensim.corpora.dictionary.Dictionary`}
          Other dictionary.
  
      Return
      ------
      :class:`gensim.models.VocabTransform`
          Transformation object.
  
      Examples
      --------
      .. sourcecode:: pycon
  
          >>> from gensim.corpora import Dictionary
          >>>
          >>> corpus_1, corpus_2 = [["a", "b", "c"]], [["a", "f", "f"]]
          >>> dct_1, dct_2 = Dictionary(corpus_1), Dictionary(corpus_2)
          >>> dct_1.doc2bow(corpus_2[0])
          [(0, 1)]
          >>> transformer = dct_1.merge_with(dct_2)
          >>> dct_1.doc2bow(corpus_2[0])
          [(0, 1), (3, 2)]
  
      """
      old2new = {}
      for other_id, other_token in other.items():
          if other_token in self.token2id:
              new_id = self.token2id[other_token]
          else:
              new_id = len(self.token2id)
              self.token2id[other_token] = new_id
              self.dfs[new_id] = 0
          old2new[other_id] = new_id
          try:
              self.dfs[new_id] += other.dfs[other_id]
          except Exception:
              # `other` isn't a Dictionary (probably just a dict) => ignore dfs, keep going
              pass
      try:
          self.num_docs += other.num_docs
          self.num_nnz += other.num_nnz
          self.num_pos += other.num_pos
      except Exception:
          pass
  
      import gensim.models
  
      return gensim.models.VocabTransform(old2new)
  
imports: from collections import defaultdict
  from collections.abc import Mapping
  import logging
  import itertools
  from typing import Optional, List, Tuple
  from gensim import utils
label_desc: Use image node_id 18 for calling the Dictionary obj's underlying member method code with example usage: obj.merge_with(other) and returns: gensim