code: def w2v_similarity_envelope(word_a, phrase_b, model):
      """
      calculate cosine similarity between 2 words
  
      Args:
          word_a(str):   input word a
          phrase_b(str): input word b
          model(gensim.models.Word2Vec): w2v model
  
      Returns:
          float: similarity, mean cosine similarity between 2 words
  
  
      """
      try:
          similarity = -1
          sim_scores_vec = []
          word_vec = phrase_b.split("_")  # in case wordB is a phrase
          i = 0
          for wordB in word_vec:
              # if (wordA != wordB) & ( wordA not in stopwords.words('english')):
              if word_a != wordB:
                  sim = w2v_similarity(word_a, wordB, model)
                  if sim > -1:
                      sim_scores_vec.insert(i, sim)
                      i = i + 1
          if sim_scores_vec:
              similarity = numpy.mean(sim_scores_vec)
  
          return similarity
      except ValueError:
          return -1
  
file_path: nlp-architect/examples/most_common_word_sense/feature_extraction.py
imports: import re
  import nltk
  import numpy
  from numpy import dot
  from numpy.linalg import norm
  from nlp_architect.utils.generic import license_prompt
label_desc: Use image node_id 8 for calling a global function with example usage: w2v_similarity_envelope(word_a, phrase_b, model) and returns: similarity, unknown