code: def cosine(a, b):
      ks = set(a.keys()).intersection(set(b.keys()))
      num = sum([a[k] * b[k] for k in ks])
      den = sum([v**2 for k, v in a.items()]) * sum(
          [v**2 for k, v in b.items()]
      )
      den = den**0.5
      if den == 0:
          den = 0.0001
      return 1 - num / den
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import copy
  import unittest
  import numpy
  import turicreate
  from turicreate.toolkits._main import ToolkitError
  from collections import Counter
  import sys
label_desc: Use image node_id 3 for calling a global function with example usage: cosine(a, b) and returns: unknown