Hello, I write an example. Is it what you want?
def fake_quantize(data, scale):
    with torch.no_grad():
        data[:] = torch.round(data[:] * scale) / scale

class Net(nn.Module):
    def __init__(self):
        super().__init__()
        self.body = nn.Conv2d(3, 3, 3)
    
    def forward(self, x):
        out = self.body(x)
        print("before quantize:", out)
        fake_quantize(out, torch.rand(1) * 100)
        print("after quantize:", out)
        return out 


net = Net()
y = net.forward(torch.rand(10, 3, 6, 6))
loss = y.sum()
loss.backward()
print(y)