Grid_sampling padding mode

I am a big fan of the grid_sampling method in

I now face a case, where all my images have white background, but the padding mode only allows for zero padding (black). Can someone guide me through the steps for extending the function with constant padding (e.g. all white)?