code: def test_cosine_distance_with_negative_samples():
      a = np.array(
          [
              [1.0, 1.0, 0.0, 0.0, 0.0],
              [0.0, 1.0, 1.0, 0.0, 0.0],
              [0.0, 0.0, 1.0, 1.0, 0.0],
              [0.0, 0.0, 0.0, 1.0, 1.0],
              [1.0, 0.0, 0.0, 0.0, 1.0],
          ],
          dtype=np.float32,
      )
      b = np.array(
          [
              [1.0, 1.0, 0.0, 0.0, 0.0],
              [0.0, 1.0, 1.0, 0.0, 0.0],
              [0.0, 0.0, 1.0, 1.0, 0.0],
              [0.0, 0.0, 0.0, 1.0, 1.0],
              [1.0, 0.0, 0.0, 0.0, 1.0],
          ],
          dtype=np.float32,
      )
  
      qry = C.sequence.input_variable(shape=(5))
      doc = C.sequence.input_variable(shape=(5))
      num_neg_samples = 2
      model = C.cosine_distance_with_negative_samples(
          qry, doc, shift=1, num_negative_samples=num_neg_samples
      )
      result = model.eval({qry: [a], doc: [b]})
  
      # We expect 1 row per minibatch
      np.allclose(len(result), a.shape[0])
  
      # We expect the number of columns to be number of negative samples + 1
      np.allclose(result[0].shape[1], num_neg_samples + 1)
  
      # The first value is exact match, second ony 1 element match and last one is 0 match
      np.allclose(result[0], np.tile([1, 0.5, 0.0], (a.shape[0], 1)))
  
file_path: CNTK/bindings/python/cntk/losses/tests/cosine_distance_test.py
imports: import numpy
  import pytest
  import cntk
label_desc: Use image node_id 2 for calling a global function with example usage: test_cosine_distance_with_negative_samples() without return types