code: def cosine_distances(X, Y=None):
      """Compute cosine distance between samples in X and Y.
  
      Cosine distance is defined as 1.0 minus the cosine similarity.
  
      Read more in the :ref:`User Guide <metrics>`.
  
      Parameters
      ----------
      X : array_like, sparse matrix
          with shape (n_samples_X, n_features).
  
      Y : array_like, sparse matrix (optional)
          with shape (n_samples_Y, n_features).
  
      Returns
      -------
      distance matrix : Tensor
          A tensor with shape (n_samples_X, n_samples_Y).
  
      See also
      --------
      mars.learn.metrics.pairwise.cosine_similarity
      mars.tensor.spatial.distance.cosine : dense matrices only
      """
      op = CosineDistances(x=X, y=Y, dtype=np.dtype(np.float64))
      return op(X, y=Y)
  
file_path: mars/mars/learn/metrics/pairwise/cosine.py
imports: import numpy
  from ....None import opcodes
  from ....core import recursive_tile
  from ....serialization.serializables import KeyField
  from ....None import tensor
  from ....tensor.core import TensorOrder
  from ...preprocessing import normalize
  from .core import PairwiseDistances
label_desc: Use image node_id 2 for calling a global function with example usage: cosine_distances(X, Y) and returns: op