class_docstr: Objects of this class realize the translation matrix which maps the source language to the target language.
  The main methods are:
  
  We map it to the other language space by computing z = Wx, then return the
  word whose representation is close to z.
  
  For details on use, see the tutorial notebook [3]_
  
  Examples
  --------
  .. sourcecode:: pycon
  
      >>> from gensim.models import KeyedVectors
      >>> from gensim.test.utils import datapath
      >>> en = datapath("EN.1-10.cbow1_wind5_hs0_neg10_size300_smpl1e-05.txt")
      >>> it = datapath("IT.1-10.cbow1_wind5_hs0_neg10_size300_smpl1e-05.txt")
      >>> model_en = KeyedVectors.load_word2vec_format(en)
      >>> model_it = KeyedVectors.load_word2vec_format(it)
      >>>
      >>> word_pairs = [
      ...     ("one", "uno"), ("two", "due"), ("three", "tre"), ("four", "quattro"), ("five", "cinque"),
      ...     ("seven", "sette"), ("eight", "otto"),
      ...     ("dog", "cane"), ("pig", "maiale"), ("fish", "cavallo"), ("birds", "uccelli"),
      ...     ("apple", "mela"), ("orange", "arancione"), ("grape", "acino"), ("banana", "banana")
      ... ]
      >>>
      >>> trans_model = TranslationMatrix(model_en, model_it)
      >>> trans_model.train(word_pairs)
      >>> trans_model.translate(["dog", "one"], topn=3)
      OrderedDict([('dog', [u'cane', u'gatto', u'cavallo']), ('one', [u'uno', u'due', u'tre'])])
  
  
  References
  ----------
  .. [3] https://github.com/RaRe-Technologies/gensim/blob/3.2.0/docs/notebooks/translation_matrix.ipynb
class_docstr_tok: ["Objects","of","this","class","realize","the","translation","matrix","which","maps","the","source","language","to","the","target","language",".","The","main","methods","are",":","We","map","it","to","the","other","language","space","by","computing","z","=","Wx",",","then","return","the","word","whose","representation","is","close","to","z",".","For","details","on","use",",","see","the","tutorial","notebook","[","3","]","_","Examples","--","--","--","--","..","sourcecode",":",":","pycon",">",">",">","from","gensim.models","import","KeyedVectors",">",">",">","from","gensim.test.utils","import","datapath",">",">",">","en","=","datapath","(","``","EN.1-10.cbow1_wind5_hs0_neg10_size300_smpl1e-05.txt","''",")",">",">",">","it","=","datapath","(","``","IT.1-10.cbow1_wind5_hs0_neg10_size300_smpl1e-05.txt","''",")",">",">",">","model_en","=","KeyedVectors.load_word2vec_format","(","en",")",">",">",">","model_it","=","KeyedVectors.load_word2vec_format","(","it",")",">",">",">",">",">",">","word_pairs","=","[","...","(","``","one","''",",","``","uno","''",")",",","(","``","two","''",",","``","due","''",")",",","(","``","three","''",",","``","tre","''",")",",","(","``","four","''",",","``","quattro","''",")",",","(","``","five","''",",","``","cinque","''",")",",","...","(","``","seven","''",",","``","sette","''",")",",","(","``","eight","''",",","``","otto","''",")",",","...","(","``","dog","''",",","``","cane","''",")",",","(","``","pig","''",",","``","maiale","''",")",",","(","``","fish","''",",","``","cavallo","''",")",",","(","``","birds","''",",","``","uccelli","''",")",",","...","(","``","apple","''",",","``","mela","''",")",",","(","``","orange","''",",","``","arancione","''",")",",","(","``","grape","''",",","``","acino","''",")",",","(","``","banana","''",",","``","banana","''",")","...","]",">",">",">",">",">",">","trans_model","=","TranslationMatrix","(","model_en",",","model_it",")",">",">",">","trans_model.train","(","word_pairs",")",">",">",">","trans_model.translate","(","[","``","dog","''",",","``","one","''","]",",","topn=3",")","OrderedDict","(","[","(","'dog","'",",","[","u'cane","'",",","u'gatto","'",",","u'cavallo","'","]",")",",","(","'one","'",",","[","u'uno","'",",","u'due","'",",","u'tre","'","]",")","]",")","References","--","--","--","--","--","..","[","3","]","https",":","\/\/github.com\/RaRe-Technologies\/gensim\/blob\/3.2.0\/docs\/notebooks\/translation_matrix.ipynb"]
docstr: Build the translation matrix to map from source space to target space.
  
  Parameters
  ----------
  word_pairs : list of (str, str), optional
      Pairs of words that will be used for training.
docstr_tok: ["Build","the","translation","matrix","to","map","from","source","space","to","target","space",".","Parameters","--","--","--","--","--","word_pairs",":","list","of","(","str",",","str",")",",","optional","Pairs","of","words","that","will","be","used","for","training","."]
code: def train(self, word_pairs):
      """Build the translation matrix to map from source space to target space.
  
      Parameters
      ----------
      word_pairs : list of (str, str), optional
          Pairs of words that will be used for training.
  
      """
      self.source_word, self.target_word = zip(*word_pairs)
  
      self.source_space = Space.build(
          self.source_lang_vec, set(self.source_word)
      )
      self.target_space = Space.build(
          self.target_lang_vec, set(self.target_word)
      )
  
      self.source_space.normalize()
      self.target_space.normalize()
  
      m1 = self.source_space.mat[
          [
              self.source_space.word2index[item]
              for item in self.source_word
          ],
          :,
      ]
      m2 = self.target_space.mat[
          [
              self.target_space.word2index[item]
              for item in self.target_word
          ],
          :,
      ]
  
      self.translation_matrix = np.linalg.lstsq(m1, m2, -1)[0]
  
imports: import warnings
  from collections import OrderedDict
  import numpy
  from gensim import utils
label_desc: Use image node_id 2 for calling the TranslationMatrix obj's underlying member method code with example usage: obj.train(word_pairs) without return types