code: def _cosine_distance(v1, v2, cosine_norm=True, eps=1e-6):
      """
      Only requires `tf.reduce_sum(v1 * v2, axis=-1)`.
  
      :param v1: [batch, time_steps(v1), 1, m, d]
      :param v2: [batch, 1, time_steps(v2), m, d]
      :param cosine_norm: True
      :param eps: 1e-6
      :return: [batch, time_steps(v1), time_steps(v2), m]
      """
      cosine_numerator = tf.reduce_sum(v1 * v2, axis=-1)
      if not cosine_norm:
          return K.tanh(cosine_numerator)
      v1_norm = K.sqrt(
          tf.maximum(tf.reduce_sum(tf.square(v1), axis=-1), eps)
      )
      v2_norm = K.sqrt(
          tf.maximum(tf.reduce_sum(tf.square(v2), axis=-1), eps)
      )
      return cosine_numerator / v1_norm / v2_norm
  
imports: import tensorflow
  from keras import backend
  from keras.engine import Layer
  from matchzoo.contrib.layers.attention_layer import AttentionLayer
label_desc: Use image node_id 8 for calling a global function with example usage: _cosine_distance(v1, v2, cosine_norm, eps) and returns: unknown, K