Thanks @ptrblck! I get your point! And I am not doing this correctly! I will explain myself again.
I have older code, which has this code:
 transform_train = transforms.Compose([
                transforms.ToTensor(),
                transforms.Lambda(lambda x: F.pad(Variable(x.unsqueeze(0), require_grad=False, volatile=True),(4,4,4,4),mode='reflect').data.squeeze()),

Where we have this line of code:
Variable(x.unsqueeze(0), require_grad=False, volatile=True)
Now Since Volatile is Deprecated now, I was wondering what changes should I make to the existing code, to still make it work. Since it is replaced by with torch.no_grad(), I was trying out that.
Now As rightly pointed by you, The way I have written it, would not work. So how should I go about implementing this.
Regards,
Nitin