Weighted Median Function

PyTorch’s median function does not take weights for data points. Can you help me implementing the Weighted Median function?