code: def cosine_similarity(evaluated_model, reference_model):
      """
      Computes cosine similarity of two text documents. Each document
      has to be represented as TF model of non-empty document.
  
      :returns float:
          0 <= cos <= 1, where 0 means independence and 1 means
          exactly the same.
      """
      if not (
          isinstance(evaluated_model, TfModel)
          and isinstance(reference_model, TfModel)
      ):
          raise ValueError(
              "Arguments has to be instances of 'sumy.models.TfDocumentModel'"
          )
  
      terms = frozenset(evaluated_model.terms) | frozenset(
          reference_model.terms
      )
  
      numerator = 0.0
      for term in terms:
          numerator += evaluated_model.term_frequency(
              term
          ) * reference_model.term_frequency(term)
  
      denominator = (
          evaluated_model.magnitude * reference_model.magnitude
      )
      if denominator == 0.0:
          raise ValueError(
              "Document model can't be empty. Given %r & %r"
              % (evaluated_model, reference_model)
          )
  
      return numerator / denominator
  
imports: from __future__ import absolute_import
  from __future__ import division, print_function, unicode_literals
  from ..models import TfDocumentModel
label_desc: Use image node_id 1 for calling a global function with example usage: cosine_similarity(evaluated_model, reference_model) and returns: unknown