code: def pairwise_cos_distance(A, B):
      
      normalized_A = tf.nn.l2_normalize(A, dim=1)
      normalized_B = tf.nn.l2_normalize(B, dim=1)
      prod = tf.matmul(normalized_A, normalized_B, adjoint_b=True)
      return 1 - prod
docs: Pairwise cosine distance between two matrices.
      :param A: a matrix.
      :param B: a matrix.
  
      :returns: A tensor for the pairwise cosine between A and B.