code: def test_cos_distane_backward():
      x = C.sequence.input_variable(
          shape=(2,), sequence_axis=C.Axis("B"), needs_gradient=True
      )
      y = C.sequence.input_variable(
          shape=(2,), sequence_axis=C.Axis("B"), needs_gradient=True
      )
      z = C.cosine_distance(x, y)
      a = np.reshape(np.float32([0.25, 0.5, 0.1, 1]), (1, 2, 2))
      b = np.reshape(np.float32([-0.5, 1.5, -0.3, -1]), (1, 2, 2))
      bwd, fwd = z.forward({x: a, y: b}, [z.output], set([z.output]))
      value = list(fwd.values())[0]
      expected = [[0.707107, -0.981665]]
      assert np.allclose(value, expected)
      grad = z.backward(
          bwd, {z.output: np.ones_like(value)}, set([x, y])
      )
      x_driv_expected = np.ndarray(
          (1, 2, 2),
          dtype=np.float32,
          buffer=np.float32([-1.131371, 0.565686, -0.188727, 0.018873]),
      )
      y_driv_expected = np.ndarray(
          (1, 2, 2),
          dtype=np.float32,
          buffer=np.float32([0.424264, 0.141421, -0.174876, 0.052463]),
      )
      assert np.all(np.absolute(grad[x] - x_driv_expected) < 1e-6)
      assert np.all(np.absolute(grad[y] - y_driv_expected) < 1e-6)
  
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 5 for calling a global function with example usage: test_cos_distane_backward() without return types