code: def cosine_similarity(x1, x2, *, axis=1, eps=1e-08):
      if len(x1.shape) == len(x2.shape) and len(x2.shape) >= 2:
          numerator = ivy.sum(x1 * x2, axis=axis)
          x1_squared_norm = ivy.sum(ivy.square(x1), axis=axis)
          x2_squared_norm = ivy.sum(ivy.square(x2), axis=axis)
      else:
          numerator = ivy.sum(x1 * x2)
          x1_squared_norm = ivy.sum(ivy.square(x1))
          x2_squared_norm = ivy.sum(ivy.square(x2))
  
      x1_norm = ivy.sqrt(x1_squared_norm)
      x2_norm = ivy.sqrt(x2_squared_norm)
      norm_mm = x1_norm * x2_norm
      denominator = ivy.maximum(norm_mm, eps)
  
      cosine = numerator / denominator
      return cosine
  
file_path: ivy/ivy/functional/frontends/paddle/nn/functional/common.py
imports: import ivy
  from ivy.func_wrapper import with_supported_dtypes
  from ivy.functional.frontends.paddle.func_wrapper import to_ivy_arrays_and_back
label_desc: Use image node_id 1 for calling a global function with example usage: cosine_similarity(x1, x2) and returns: cosine