class_docstr: A matrix that implements cosine distance search against it.
  
  cosine_distance = 1 - cosine_similarity
  
  Note: We want items that are more similar to be closer to zero so we are
  going to instead return 1 - cosine_similarity. We do this so similarity
  and distance metrics can be treated the same way.
  
  Assumes unit-vectors and takes some shortucts:
    * Uses integers instead of floats
    * 1**2 == 1 so that operation can be skipped
class_docstr_tok: ["A","matrix","that","implements","cosine","distance","search","against","it",".","cosine_distance","=","1","-","cosine_similarity","Note",":","We","want","items","that","are","more","similar","to","be","closer","to","zero","so","we","are","going","to","instead","return","1","-","cosine_similarity",".","We","do","this","so","similarity","and","distance","metrics","can","be","treated","the","same","way",".","Assumes","unit-vectors","and","takes","some","shortucts",":","*","Uses","integers","instead","of","floats","*","1","*","*","2","==","1","so","that","operation","can","be","skipped"]
docstr: Vectorised cosine distance
code: def _distance(self, a_matrix):
      """Vectorised cosine distance"""
      # what is the implmentation of transpose? can i change the order?
      dprod = self.matrix.dot(a_matrix.transpose()).transpose() * 1.0
  
      a_root_sum_square = _np.asarray(a_matrix.sum(axis=1)).reshape(-1)
      a_root_sum_square = a_root_sum_square.reshape(
          len(a_root_sum_square), 1
      )
      a_root_sum_square = _np.sqrt(a_root_sum_square)
  
      magnitude = 1.0 / (
          a_root_sum_square * self.matrix_root_sum_square
      )
  
      return 1 - dprod.multiply(magnitude).toarray()
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import abc
  import numpy
  import scipy.sparse
  import scipy.spatial.distance
label_desc: Use image node_id 5 for calling the UnitCosineDistance obj's underlying member method code with example usage: obj._distance(a_matrix) and returns: unknown