class_docstr: Focal loss for object detection.
  Args:
      gamma (`float`): hyper-parameter of focal loss
      alpha (`float`): hyper-parameter of focal loss
      size_average (`bool`): whether to average the loss
docstr: Args:
      input_s (`float`): predicted result
      target (`float`): ground truth
docstr_tok: ["Args",":","input_s","(","`","float","`",")",":","predicted","result","target","(","`","float","`",")",":","ground","truth"]
code: def forward(self, input_s: torch.Tensor, target: torch.Tensor):
      """
      Args:
          input_s (`float`): predicted result
          target (`float`): ground truth
      """
      if input_s.dim() > 2:
          input_s = input_s.view(
              input_s.size(0), input_s.size(1), -1
          )  # N,C,H,W => N,C,H*W
          input_s = input_s.transpose(1, 2)  # N,C,H*W => N,H*W,C
          input_s = input_s.contiguous().view(
              -1, input_s.size(2)
          )  # N,H*W,C => N*H*W,C
      target = target.view(-1, 1)
  
      logpt = F.log_softmax(input_s)
      logpt = logpt.gather(1, target)
      logpt = logpt.view(-1)
      pt = Variable(logpt.data.exp())
  
      if self.alpha is not None:
          if self.alpha.type() != input_s.data.type():
              self.alpha = self.alpha.type_as(input_s.data)
          at = self.alpha.gather(0, target.data.view(-1))
          logpt = logpt * Variable(at)
  
      loss = -1 * (1 - pt) ** self.gamma * logpt
      if self.size_average:
          return loss.mean()
      else:
          return loss.sum()
  
imports: import torch
  import torch.nn.functional
  from torch import nn
  from torch.autograd import Variable
label_desc: Use image node_id 2 for calling the FocalLoss obj's underlying member method code with example usage: obj.forward(input_s, target) and returns: loss, loss