class_docstr: Compute cosine similarity against a corpus of documents by storing the index matrix in memory.
  
  Unless the entire matrix fits into main memory, use :class:`~gensim.similarities.docsim.Similarity` instead.
  
  Examples
  --------
  .. sourcecode:: pycon
  
      >>> from gensim.test.utils import common_corpus, common_dictionary
      >>> from gensim.similarities import MatrixSimilarity
      >>>
      >>> query = [(1, 2), (5, 4)]
      >>> index = MatrixSimilarity(common_corpus, num_features=len(common_dictionary))
      >>> sims = index[query]
class_docstr_tok: ["Compute","cosine","similarity","against","a","corpus","of","documents","by","storing","the","index","matrix","in","memory",".","Unless","the","entire","matrix","fits","into","main","memory",",","use",":","class",":","`","~gensim.similarities.docsim.Similarity","`","instead",".","Examples","--","--","--","--","..","sourcecode",":",":","pycon",">",">",">","from","gensim.test.utils","import","common_corpus",",","common_dictionary",">",">",">","from","gensim.similarities","import","MatrixSimilarity",">",">",">",">",">",">","query","=","[","(","1",",","2",")",",","(","5",",","4",")","]",">",">",">","index","=","MatrixSimilarity","(","common_corpus",",","num_features=len","(","common_dictionary",")",")",">",">",">","sims","=","index","[","query","]"]
docstr: Get similarity between `query` and this index.
  
  Warnings
  --------
  Do not use this function directly, use the :class:`~gensim.similarities.docsim.MatrixSimilarity.__getitem__`
  instead.
  
  Parameters
  ----------
  query : {list of (int, number), iterable of list of (int, number), :class:`scipy.sparse.csr_matrix`}
      Document or collection of documents.
  
  Return
  ------
  :class:`numpy.ndarray`
      Similarity matrix.
code: def get_similarities(self, query):
      """Get similarity between `query` and this index.
  
      Warnings
      --------
      Do not use this function directly, use the :class:`~gensim.similarities.docsim.MatrixSimilarity.__getitem__`
      instead.
  
      Parameters
      ----------
      query : {list of (int, number), iterable of list of (int, number), :class:`scipy.sparse.csr_matrix`}
          Document or collection of documents.
  
      Return
      ------
      :class:`numpy.ndarray`
          Similarity matrix.
  
      """
      is_corpus, query = utils.is_corpus(query)
      if is_corpus:
          query = numpy.asarray(
              [
                  matutils.sparse2full(vec, self.num_features)
                  for vec in query
              ],
              dtype=self.index.dtype,
          )
      else:
          if scipy.sparse.issparse(query):
              query = query.toarray()  # convert sparse to dense
          elif isinstance(query, numpy.ndarray):
              pass
          else:
              # default case: query is a single vector in sparse gensim format
              query = matutils.sparse2full(query, self.num_features)
          query = numpy.asarray(query, dtype=self.index.dtype)
  
      # do a little transposition dance to stop numpy from making a copy of
      # self.index internally in numpy.dot (very slow).
      result = numpy.dot(
          self.index, query.T
      ).T  # return #queries x #index
      return result
  
imports: import logging
  import itertools
  import os
  import heapq
  import warnings
  import numpy
  import scipy.sparse
  from gensim import interfaces, utils, matutils
label_desc: Use image node_id 3 for calling the MatrixSimilarity obj's underlying member method code with example usage: obj.get_similarities(query) and returns: result