def focal_loss(input: paddle.Tensor,
               target: paddle.Tensor,
               alpha: float,
               gamma: float=2.0,
               reduction: str='none',
               eps: float=1e-8) -> paddle.Tensor:
    r"""Function that computes Focal loss.

    See :class:`~kornia.losses.FocalLoss` for details.
    """
    if not paddle.is_tensor(input):
        raise TypeError("Input type is not a torch.Tensor. Got {}".format(
            type(input)))

    if not len(input.shape) >= 2:
        raise ValueError("Invalid input shape, we expect BxCx*. Got: {}".format(
            input.shape))

    if input.shape[0] != target.shape[0]:
        raise ValueError(
            'Expected input batch_size ({}) to match target batch_size ({}).'.
            format(input.shape[0], target.shape[0]))

    n = input.shape[0]
    out_size = (n, ) + tuple(input.shape[2:])
    if target.shape[1:] != input.shape[2:]:
        raise ValueError('Expected target size {}, got {}'.format(out_size,
                                                                  target.shape))
    if (isinstance(input.place, paddle.CUDAPlace) and
            isinstance(target.place, paddle.CPUPlace)) | (isinstance(
                input.place, paddle.CPUPlace) and isinstance(target.place,
                                                             paddle.CUDAPlace)):
        raise ValueError(
            "input and target must be in the same device. Got: {} and {}".
            format(input.place, target.place))

    # compute softmax over the classes axis
    input_soft: paddle.Tensor = F.softmax(input, axis=1) + eps

    # create the labels one hot tensor
    target_one_hot: paddle.Tensor = paddle.to_tensor(
        F.one_hot(
            target, num_classes=input.shape[1]).cast(input.dtype),
        place=input.place)

    # compute the actual focal loss
    weight = paddle.pow(-input_soft + 1., gamma)

    focal = -alpha * weight * paddle.log(input_soft)
    loss_tmp = paddle.sum(target_one_hot * focal, axis=1)

    if reduction == 'none':
        loss = loss_tmp
    elif reduction == 'mean':
        loss = paddle.mean(loss_tmp)
    elif reduction == 'sum':
        loss = paddle.sum(loss_tmp)
    else:
        raise NotImplementedError("Invalid reduction mode: {}".format(
            reduction))
    return loss
Function that computes Focal loss.

    See :class:`~kornia.losses.FocalLoss` for details.
    
ppdet/modeling/losses/clrnet_loss.py