code: def cosine_similarity(vec1, vec2) -> float:
      """Compute the cosine similarity of two vectors."""
      if vec1.all() == 0 or vec2.all() == 0:
          return 0.0
      xp = get_array_module(vec1)
      norm1 = xp.linalg.norm(vec1)
      norm2 = xp.linalg.norm(vec2)
      if norm1 == norm2:
          return 1.0
      return xp.dot(vec1, vec2) / (norm1 * norm2)
  
file_path: sense2vec/sense2vec/util.py
imports: from typing import Union, List, Tuple, Set
  import re
  from spacy.tokens import Doc, Token, Span
  from spacy.util import filter_spans
  from thinc.api import get_array_module
  import catalogue
label_desc: Use image node_id 9 for calling a global function with example usage: cosine_similarity(vec1, vec2) and returns: unknown, int, int