Refer to torch.nn.ZeroPad, the asymmetric padding is now available by passing a tuple to the Pad function.
For example:
>>> input = torch.randn(1, 1, 3, 3)
>>> input
tensor([[[[-1.7800, 0.6112, -0.0166],
[-2.1496, -0.5789, 0.8997],
[-0.5621, 0.9050, 0.4039]]]])
>>> m = torch.nn.ZeroPad2d((1, 2, 1, 2))
>>> m
tensor([[[[ 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000],
[ 0.0000, -1.7800, 0.6112, -0.0166, 0.0000, 0.0000],
[ 0.0000, -2.1496, -0.5789, 0.8997, 0.0000, 0.0000],
[ 0.0000, -0.5621, 0.9050, 0.4039, 0.0000, 0.0000],
[ 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000],
[ 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000]]]])