How to use weighted SmoothL1Loss?

I noticed that this was implemented here:

However, I couldn’t find docs about calling this detectron module.
How should we call this function in PyTorch?
In , we couldn’t pass the weights arguments as

Thank you in advance.

It seems this can be implemented with simple lines:

def weighted_smooth_l1_loss(input, target, weights):
    # type: (Tensor, Tensor, Tensor) -> Tensor
    t = torch.abs(input - target)
    return weights * torch.where(t < 1, 0.5 * t ** 2, t - 0.5)

Then apply reduction such as torch.mean subsequently.