    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()
Args:
input_s (`float`): predicted result
target (`float`): ground truth
towhee/models/loss/focal_loss.py