class_docstr: Compute negative WMD similarity against a corpus of documents.
  
  Check out `the Gallery <https://radimrehurek.com/gensim/auto_examples/tutorials/run_wmd.html>`__
  for more examples.
  
  When using this code, please consider citing the following papers:
  
  * `Rémi Flamary et al. "POT: Python Optimal Transport"
    <https://jmlr.org/papers/v22/20-451.html>`_
  * `Matt Kusner et al. "From Word Embeddings To Document Distances"
    <http://proceedings.mlr.press/v37/kusnerb15.pdf>`_
  
  Example
  -------
  .. sourcecode:: pycon
  
      >>> from gensim.test.utils import common_texts
      >>> from gensim.models import Word2Vec
      >>> from gensim.similarities import WmdSimilarity
      >>>
      >>> model = Word2Vec(common_texts, vector_size=20, min_count=1)  # train word-vectors
      >>>
      >>> index = WmdSimilarity(common_texts, model.wv)
      >>> # Make query.
      >>> query = ['trees']
      >>> sims = index[query]
class_docstr_tok: ["Compute","negative","WMD","similarity","against","a","corpus","of","documents",".","Check","out","`","the","Gallery","<","https",":","\/\/radimrehurek.com\/gensim\/auto_examples\/tutorials\/run_wmd.html",">","`","__","for","more","examples",".","When","using","this","code",",","please","consider","citing","the","following","papers",":","*","`","R\u00e9mi","Flamary","et","al",".","``","POT",":","Python","Optimal","Transport","''","<","https",":","\/\/jmlr.org\/papers\/v22\/20-451.html",">","`","_","*","`","Matt","Kusner","et","al",".","``","From","Word","Embeddings","To","Document","Distances","''","<","http",":","\/\/proceedings.mlr.press\/v37\/kusnerb15.pdf",">","`","_","Example","--","--","--","-","..","sourcecode",":",":","pycon",">",">",">","from","gensim.test.utils","import","common_texts",">",">",">","from","gensim.models","import","Word2Vec",">",">",">","from","gensim.similarities","import","WmdSimilarity",">",">",">",">",">",">","model","=","Word2Vec","(","common_texts",",","vector_size=20",",","min_count=1",")","#","train","word-vectors",">",">",">",">",">",">","index","=","WmdSimilarity","(","common_texts",",","model.wv",")",">",">",">","#","Make","query",".",">",">",">","query","=","[","'trees","'","]",">",">",">","sims","=","index","[","query","]"]
docstr: Get similarity between `query` and this index.
  
  Warnings
  --------
  Do not use this function directly; use the `self[query]` syntax instead.
  
  Parameters
  ----------
  query : {list of str, iterable of list of str}
      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 `self[query]` syntax instead.
  
      Parameters
      ----------
      query : {list of str, iterable of list of str}
          Document or collection of documents.
  
      Return
      ------
      :class:`numpy.ndarray`
          Similarity matrix.
  
      """
      if isinstance(query, numpy.ndarray):
          # Convert document indexes to actual documents.
          query = [self.corpus[i] for i in query]
  
      if not query or not isinstance(query[0], list):
          query = [query]
  
      n_queries = len(query)
      result = []
      for qidx in range(n_queries):
          # Compute similarity for each query.
          qresult = [
              self.wv.wmdistance(document, query[qidx])
              for document in self.corpus
          ]
          qresult = numpy.array(qresult)
          qresult = 1.0 / (
              1.0 + qresult
          )  # Similarity is the negative of the distance.
  
          # Append single query result to list of all results.
          result.append(qresult)
  
      if len(result) == 1:
          # Only one query.
          result = result[0]
      else:
          result = numpy.array(result)
  
      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 WmdSimilarity obj's underlying member method code with example usage: obj.get_similarities(query) and returns: result