class_docstr: This implements the `Barron loss <https://arxiv.org/pdf/1701.03077.pdf>`_.
code: def __init__(self, alpha, size_average, c):
      super(BarronLoss, self).__init__()
  
      self.size_average = size_average
      self.alpha = alpha
      self.c = c
      self.z = max(1.0, 2.0 - self.alpha)
  
      # define all three losses:
      def _forward_zero(diff):
          out = diff.div(self.c).pow(2.0).mul(0.5).add(1.0).log()
          return out
  
      def _forward_inf(diff):
          out = 1.0 - diff.div(self.c).pow(2.0).mul(-0.5).exp()
          return out
  
      def _forward(diff):
          out = (
              diff.div(self.c)
              .pow(2.0)
              .div(self.z)
              .add(1.0)
              .pow(self.alpha / 2.0)
          )
          out.add_(-1.0).mul_(self.z / self.alpha)
          return out
  
      # set the correct loss:
      if self.alpha == 0.0:
          self._forward = _forward_zero
      elif self.alpha == -float("inf") or self.alpha == float("inf"):
          self._forward = _forward_inf
      else:
          self._forward = _forward
  
file_path: ClassyVision/classy_vision/losses/barron_loss.py
imports: from typing import Any, Dict
  import torch
  from .None import ClassyLoss, register_loss
label_desc: Use image node_id 1 to create a new BarronLoss object from inherited base classes: ClassyLoss with example: obj = BarronLoss(alpha, size_average, c)