code: def hinge_embedding_loss(
      input: Union[ivy.Array, ivy.NativeArray],
      target: Union[ivy.Array, ivy.NativeArray],
      *,
      margin: float = 1.0,
      reduction: str = "mean",
  ) -> ivy.Array:
      r"""Measures loss from input `x` and label `y` with values 1 or -1. It
      evaluates if two inputs are similar or not, often used for embedding or
      semi-supervised learning.
  
      Loss for the `n`-th sample:
          .. math::
              l_n = \begin{cases}
                  x_n, & \text{if}\; y_n = 1,\\
                  \max \{0, margin - x_n\}, & \text{if}\; y_n = -1,
              \end{cases}
  
      Total loss:
          .. math::
              \ell(x, y) = \begin{cases}
                  \operatorname{mean}(L), & \text{if reduction} = \text{`mean';}\\
                  \operatorname{sum}(L),  & \text{if reduction} = \text{`sum'.}
              \end{cases}
  
      where :math:`L = \{l_1,\dots,l_N\}^\top` .
  
      Parameters
      ----------
      input
          Input tensor with dtype float.
          The shape is [N, \*], where N is batch size and `\*` represents
          any number of additional dimensions.
      label
          Label tensor containing 1 or -1 with dtype float32 or float64.
          Its shape matches that of the input.
      margin
          Sets the hyperparameter margin. Determines the necessary input size
          for hinge_embedding_loss calculations when label is -1. Inputs smaller
          than the margin are minimized with hinge_embedding_loss.
          Default is 1.0.
      reduction
          Specifies how to aggregate the loss across the batch. Options are:
          - ``'none'``: Returns the unreduced loss.
          - ``'mean'``: Returns the mean loss.
          - ``'sum'``: Returns the summed loss.
          Default is ``'mean'``.
  
      Shape
      -----
          - Input: :math:`(*)` where :math:`*` means, any number of dimensions. \
          The sum operation operates over all the elements.
          - Target: :math:`(*)`, same shape as the input
          - Output: scalar. If :attr:`reduction` is ``'none'``,
          then same shape as the input
  
      Returns
      -------
      ret
          Hinge embedding loss calculated from the input and label,
          shaped based on the reduction method.
  
      Examples
      --------
      >>> input_tensor = ivy.array([1, 2, 3, 4], dtype=ivy.float64)
      >>> target_tensor = ivy.array([1, 1, 1, 1], dtype=ivy.float64)
      >>> loss = ivy.hinge_embedding_loss(input_tensor, target_tensor, reduction="none")
      >>> loss
      ivy.array([1., 2., 3., 4.])
  
      >>> input_tensor = ivy.array([21, 22], dtype=ivy.float32)
      >>> target_tensor = ivy.array([-1, 1], dtype=ivy.float32)
      >>> loss = ivy.hinge_embedding_loss(input_tensor,target_tensor,
      ...                                 margin=2.0, reduction="sum")
      >>> loss
      ivy.array(22.)
      """
      return ivy.current_backend().hinge_embedding_loss(
          input,
          target,
          margin=margin,
          reduction=reduction,
      )
  
file_path: ivy/ivy/functional/ivy/experimental/losses.py
imports: from typing import Union, Optional
  import ivy
  from ivy.func_wrapper import handle_nestable, inputs_to_ivy_arrays, handle_array_like_without_promotion, handle_array_function, to_native_arrays_and_back
  from ivy.utils.exceptions import handle_exceptions
label_desc: Use image node_id 8 for calling a global function with example usage: hinge_embedding_loss(input, target) and returns: ivy