docstr: Test cosine_similarity()
docstr_tok: ["Test","cosine_similarity","(",")"]
code: def test_cosine_similarity(self):
      """Test cosine_similarity()"""
      accumulator = text_analysis.InvertedIndexAccumulator(
          {1, 2}, self.dictionary
      )
      accumulator._inverted_index = {0: {2, 3, 4}, 1: {3, 5}}
      accumulator._num_docs = 5
      obtained = indirect_confirmation_measure.cosine_similarity(
          self.segmentation,
          accumulator,
          self.topics,
          self.measure,
          self.gamma,
      )
  
      # The steps involved in this calculation are as follows:
      # 1. Take (1, array([1, 2]). Take w' which is 1.
      # 2. Calculate nlr(1, 1), nlr(1, 2). This is our first vector.
      # 3. Take w* which is array([1, 2]).
      # 4. Calculate nlr(1, 1) + nlr(2, 1). Calculate nlr(1, 2), nlr(2, 2). This is our second vector.
      # 5. Find out cosine similarity between these two vectors.
      # 6. Similarly for the second segmentation.
      expected = (
          0.6230 + 0.6230
      ) / 2.0  # To account for EPSILON approximation
      self.assertAlmostEqual(expected, obtained[0], 4)
  
      mean, std = indirect_confirmation_measure.cosine_similarity(
          self.segmentation,
          accumulator,
          self.topics,
          self.measure,
          self.gamma,
          with_std=True,
      )[0]
      self.assertAlmostEqual(expected, mean, 4)
      self.assertAlmostEqual(0.0, std, 1)
  
file_path: gensim/gensim/test/test_indirect_confirmation.py
imports: import logging
  import unittest
  import numpy
  from gensim.corpora.dictionary import Dictionary
  from gensim.topic_coherence import indirect_confirmation_measure
  from gensim.topic_coherence import text_analysis
label_desc: Use image node_id 2 for calling the TestIndirectConfirmation obj's underlying member method code with example usage: obj.test_cosine_similarity() without return types