code: def cosine_embedding_loss(
      input1, input2, label, margin=0.0, reduction="mean", name=None
  ):
      if len(label.shape) != 1:
          raise ValueError(
              "1D target tensor expected, multi-target not supported"
          )
  
      if input1.shape != input2.shape:
          raise ValueError(
              "the shape of input tensor 1 should be equal to input tensor 2, but found"
              " inputs with different sizes"
          )
  
      if len(input1.shape) > 2:
          raise ValueError(
              "1D target tensor expects 1D or 2D input tensors, but found inputs with"
              " different sizes"
          )
  
      prod_sum = (input1 * input2).sum(axis=-1)
      mag_square1 = ivy.square(input1).sum(axis=-1) + 1e-11
      mag_square2 = ivy.square(input2).sum(axis=-1) + 1e-11
      denom = ivy.sqrt(mag_square1 * mag_square2)
      cos = prod_sum / denom
      zeros = ivy.zeros_like(cos)
      pos = 1 - cos
      neg = ivy.clip(cos - margin, 0, 0)
      out_pos = ivy.where(label == 1, pos, zeros)
      out_neg = ivy.where(label == -1, neg, zeros)
      out = out_pos + out_neg
  
      if reduction == "none":
          pass
      if reduction == "mean":
          out = ivy.mean(out)
      elif reduction == "sum":
          out = ivy.sum(out)
  
      return out
  
imports: import ivy
  from ivy.func_wrapper import with_supported_dtypes
  import ivy.functional.frontends.paddle
  from ivy.utils.exceptions import handle_exceptions
  from ivy.functional.frontends.paddle.func_wrapper import inputs_to_ivy_arrays, to_ivy_arrays_and_back
label_desc: Use image node_id 5 for calling a global function with example usage: cosine_embedding_loss(input1, input2, label, margin, reduction, name) and returns: out