docstr: Get random-projection representation of the input vector or corpus.
  
  Parameters
  ----------
  bow : {list of (int, int), iterable of list of (int, int)}
      Input document or corpus.
  
  Returns
  -------
  list of (int, float)
      if `bow` is document OR
  :class:`~gensim.interfaces.TransformedCorpus`
      if `bow` is corpus.
  
  Examples
  ----------
  .. sourcecode:: pycon
  
      >>> from gensim.models import RpModel
      >>> from gensim.corpora import Dictionary
      >>> from gensim.test.utils import common_texts
      >>>
      >>> dictionary = Dictionary(common_texts)  # fit dictionary
      >>> corpus = [dictionary.doc2bow(text) for text in common_texts]  # convert texts to BoW format
      >>>
      >>> model = RpModel(corpus, id2word=dictionary)  # fit model
      >>>
      >>> # apply model to document, result is vector in BoW format, i.e. [(1, 0.3), ... ]
      >>> result = model[corpus[0]]
docstr_tok: ["Get","random-projection","representation","of","the","input","vector","or","corpus",".","Parameters","--","--","--","--","--","bow",":","{","list","of","(","int",",","int",")",",","iterable","of","list","of","(","int",",","int",")","}","Input","document","or","corpus",".","Returns","--","--","--","-","list","of","(","int",",","float",")","if","`","bow","`","is","document","OR",":","class",":","`","~gensim.interfaces.TransformedCorpus","`","if","`","bow","`","is","corpus",".","Examples","--","--","--","--","--","..","sourcecode",":",":","pycon",">",">",">","from","gensim.models","import","RpModel",">",">",">","from","gensim.corpora","import","Dictionary",">",">",">","from","gensim.test.utils","import","common_texts",">",">",">",">",">",">","dictionary","=","Dictionary","(","common_texts",")","#","fit","dictionary",">",">",">","corpus","=","[","dictionary.doc2bow","(","text",")","for","text","in","common_texts","]","#","convert","texts","to","BoW","format",">",">",">",">",">",">","model","=","RpModel","(","corpus",",","id2word=dictionary",")","#","fit","model",">",">",">",">",">",">","#","apply","model","to","document",",","result","is","vector","in","BoW","format",",","i.e",".","[","(","1",",","0.3",")",",","...","]",">",">",">","result","=","model","[","corpus","[","0","]","]"]
code: def __getitem__(self, bow):
      """Get random-projection representation of the input vector or corpus.
  
      Parameters
      ----------
      bow : {list of (int, int), iterable of list of (int, int)}
          Input document or corpus.
  
      Returns
      -------
      list of (int, float)
          if `bow` is document OR
      :class:`~gensim.interfaces.TransformedCorpus`
          if `bow` is corpus.
  
      Examples
      ----------
      .. sourcecode:: pycon
  
          >>> from gensim.models import RpModel
          >>> from gensim.corpora import Dictionary
          >>> from gensim.test.utils import common_texts
          >>>
          >>> dictionary = Dictionary(common_texts)  # fit dictionary
          >>> corpus = [dictionary.doc2bow(text) for text in common_texts]  # convert texts to BoW format
          >>>
          >>> model = RpModel(corpus, id2word=dictionary)  # fit model
          >>>
          >>> # apply model to document, result is vector in BoW format, i.e. [(1, 0.3), ... ]
          >>> result = model[corpus[0]]
  
      """
      # if the input vector is in fact a corpus, return a transformed corpus as result
      is_corpus, bow = utils.is_corpus(bow)
      if is_corpus:
          return self._apply(bow)
  
      if getattr(self, "freshly_loaded", False):
          # This is a hack to work around a bug in np, where a FORTRAN-order array
          # unpickled from disk segfaults on using it.
          self.freshly_loaded = False
          self.projection = self.projection.copy(
              "F"
          )  # simply making a fresh copy fixes the broken array
  
      vec = matutils.sparse2full(bow, self.num_terms).reshape(
          self.num_terms, 1
      ) / np.sqrt(self.num_topics)
      vec = np.asfortranarray(vec, dtype=np.float32)
      topic_dist = np.dot(
          self.projection, vec
      )  # (k, d) * (d, 1) = (k, 1)
      return [
          (topicid, float(topicvalue))
          for topicid, topicvalue in enumerate(topic_dist.flat)
          if np.isfinite(topicvalue)
          and not np.allclose(topicvalue, 0.0)
      ]
  
file_path: gensim/gensim/models/rpmodel.py
imports: import logging
  import numpy
  from gensim import interfaces, matutils, utils
label_desc: Use image node_id 4 for calling the RpModel obj's underlying member method code with example usage: obj.__getitem__(bow) and returns: unknown, self