class_docstr: Model for `Latent Semantic Indexing
  <https://en.wikipedia.org/wiki/Latent_semantic_analysis#Latent_semantic_indexing>`_.
  
  The decomposition algorithm is described in `"Fast and Faster: A Comparison of Two Streamed
  Matrix Decomposition Algorithms" <https://arxiv.org/pdf/1102.5597.pdf>`_.
  
  Notes
  -----
  * :attr:`gensim.models.lsimodel.LsiModel.projection.u` - left singular vectors,
  * :attr:`gensim.models.lsimodel.LsiModel.projection.s` - singular values,
  * ``model[training_corpus]`` - right singular vectors (can be reconstructed if needed).
  
  See Also
  --------
  `FAQ about LSI matrices
  <https://github.com/RaRe-Technologies/gensim/wiki/Recipes-&-FAQ#q4-how-do-you-output-the-u-s-vt-matrices-of-lsi>`_.
  
  Examples
  --------
  .. sourcecode:: pycon
  
      >>> from gensim.test.utils import common_corpus, common_dictionary, get_tmpfile
      >>> from gensim.models import LsiModel
      >>>
      >>> model = LsiModel(common_corpus[:3], id2word=common_dictionary)  # train model
      >>> vector = model[common_corpus[4]]  # apply model to BoW document
      >>> model.add_documents(common_corpus[4:])  # update model with new documents
      >>> tmp_fname = get_tmpfile("lsi.model")
      >>> model.save(tmp_fname)  # save model
      >>> loaded_model = LsiModel.load(tmp_fname)  # load model
class_docstr_tok: ["Model","for","`","Latent","Semantic","Indexing","<","https",":","\/\/en.wikipedia.org\/wiki\/Latent_semantic_analysis","#","Latent_semantic_indexing",">","`","_",".","The","decomposition","algorithm","is","described","in","`","``","Fast","and","Faster",":","A","Comparison","of","Two","Streamed","Matrix","Decomposition","Algorithms","''","<","https",":","\/\/arxiv.org\/pdf\/1102.5597.pdf",">","`","_",".","Notes","--","--","-","*",":","attr",":","`","gensim.models.lsimodel.LsiModel.projection.u","`","-","left","singular","vectors",",","*",":","attr",":","`","gensim.models.lsimodel.LsiModel.projection.s","`","-","singular","values",",","*","``","model","[","training_corpus","]","``","-","right","singular","vectors","(","can","be","reconstructed","if","needed",")",".","See","Also","--","--","--","--","`","FAQ","about","LSI","matrices","<","https",":","\/\/github.com\/RaRe-Technologies\/gensim\/wiki\/Recipes-","&","-FAQ","#","q4-how-do-you-output-the-u-s-vt-matrices-of-lsi",">","`","_",".","Examples","--","--","--","--","..","sourcecode",":",":","pycon",">",">",">","from","gensim.test.utils","import","common_corpus",",","common_dictionary",",","get_tmpfile",">",">",">","from","gensim.models","import","LsiModel",">",">",">",">",">",">","model","=","LsiModel","(","common_corpus","[",":3","]",",","id2word=common_dictionary",")","#","train","model",">",">",">","vector","=","model","[","common_corpus","[","4","]","]","#","apply","model","to","BoW","document",">",">",">","model.add_documents","(","common_corpus","[","4",":","]",")","#","update","model","with","new","documents",">",">",">","tmp_fname","=","get_tmpfile","(","``","lsi.model","''",")",">",">",">","model.save","(","tmp_fname",")","#","save","model",">",">",">","loaded_model","=","LsiModel.load","(","tmp_fname",")","#","load","model"]
docstr: Get the latent representation for `bow`.
  
  Parameters
  ----------
  bow : {list of (int, int), iterable of list of (int, int)}
      Document or corpus in BoW representation.
  scaled : bool, optional
      If True - topics will be scaled by the inverse of singular values.
  chunksize :  int, optional
      Number of documents to be used in each applying chunk.
  
  Returns
  -------
  list of (int, float)
      Latent representation of topics in BoW format for document **OR**
  :class:`gensim.matutils.Dense2Corpus`
      Latent representation of corpus in BoW format if `bow` is corpus.
docstr_tok: ["Get","the","latent","representation","for","`","bow","`",".","Parameters","--","--","--","--","--","bow",":","{","list","of","(","int",",","int",")",",","iterable","of","list","of","(","int",",","int",")","}","Document","or","corpus","in","BoW","representation",".","scaled",":","bool",",","optional","If","True","-","topics","will","be","scaled","by","the","inverse","of","singular","values",".","chunksize",":","int",",","optional","Number","of","documents","to","be","used","in","each","applying","chunk",".","Returns","--","--","--","-","list","of","(","int",",","float",")","Latent","representation","of","topics","in","BoW","format","for","document","*","*","OR","*","*",":","class",":","`","gensim.matutils.Dense2Corpus","`","Latent","representation","of","corpus","in","BoW","format","if","`","bow","`","is","corpus","."]
code: def __getitem__(self, bow, scaled=False, chunksize=512):
      """Get the latent representation for `bow`.
  
      Parameters
      ----------
      bow : {list of (int, int), iterable of list of (int, int)}
          Document or corpus in BoW representation.
      scaled : bool, optional
          If True - topics will be scaled by the inverse of singular values.
      chunksize :  int, optional
          Number of documents to be used in each applying chunk.
  
      Returns
      -------
      list of (int, float)
          Latent representation of topics in BoW format for document **OR**
      :class:`gensim.matutils.Dense2Corpus`
          Latent representation of corpus in BoW format if `bow` is corpus.
  
      """
      if self.projection.u is None:
          raise ValueError(
              "No training data provided - LSI model not initialized yet"
          )
  
      # if the input vector is in fact a corpus, return a transformed corpus as a result
      is_corpus, bow = utils.is_corpus(bow)
      if is_corpus and chunksize:
          # by default, transform `chunksize` documents at once, when called as `lsi[corpus]`.
          # this chunking is completely transparent to the user, but it speeds
          # up internal computations (one mat * mat multiplication, instead of
          # `chunksize` smaller mat * vec multiplications).
          return self._apply(bow, chunksize=chunksize)
  
      if not is_corpus:
          bow = [bow]
  
      # convert input to scipy.sparse CSC, then do "sparse * dense = dense" multiplication
      vec = matutils.corpus2csc(
          bow, num_terms=self.num_terms, dtype=self.projection.u.dtype
      )
      topic_dist = (
          vec.T * self.projection.u[:, : self.num_topics]
      ).T  # (x^T * u).T = u^-1 * x
  
      # # convert input to dense, then do dense * dense multiplication
      # # ± same performance as above (BLAS dense * dense is better optimized than scipy.sparse),
      # but consumes more memory
      # vec = matutils.corpus2dense(bow, num_terms=self.num_terms, num_docs=len(bow))
      # topic_dist = np.dot(self.projection.u[:, :self.num_topics].T, vec)
  
      # # use np's advanced indexing to simulate sparse * dense
      # # ± same speed again
      # u = self.projection.u[:, :self.num_topics]
      # topic_dist = np.empty((u.shape[1], len(bow)), dtype=u.dtype)
      # for vecno, vec in enumerate(bow):
      #     indices, data = zip(*vec) if vec else ([], [])
      #     topic_dist[:, vecno] = np.dot(u.take(indices, axis=0).T, np.array(data, dtype=u.dtype))
  
      if not is_corpus:
          # convert back from matrix into a 1d vec
          topic_dist = topic_dist.reshape(-1)
  
      if scaled:
          topic_dist = (
              1.0 / self.projection.s[: self.num_topics]
          ) * topic_dist  # s^-1 * u^-1 * x
  
      # convert a np array to gensim sparse vector = tuples of (feature_id, feature_weight),
      # with no zero weights.
      if not is_corpus:
          # lsi[single_document]
          result = matutils.full2sparse(topic_dist)
      else:
          # lsi[chunk of documents]
          result = matutils.Dense2Corpus(topic_dist)
      return result
  
imports: import logging
  import sys
  import time
  import numpy
  import scipy.linalg
  import scipy.sparse
  from scipy.sparse import sparsetools
  from gensim import interfaces, matutils, utils
  from gensim.models import basemodel
  from gensim.utils import is_empty
label_desc: Use image node_id 4 for calling the LsiModel obj's underlying member method code with example usage: obj.__getitem__(bow, scaled, chunksize) and returns: result, self