How to use weighted SmoothL1Loss?

I noticed that this was implemented here: https://github.com/pytorch/pytorch/blob/master/modules/detectron/smooth_l1_loss_op.cc

However, I couldn’t find docs about calling this detectron module.
How should we call this function in PyTorch?
In https://pytorch.org/docs/master/nn.html#torch.nn.SmoothL1Loss , we couldn’t pass the weights arguments as https://github.com/pytorch/pytorch/blob/master/modules/detectron/smooth_l1_loss_op.cc#L41

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.