You can use the backward hooks on the relu Module:
import torch
import torch.nn as nn

inp = torch.randn(5, requires_grad=True)
print(inp) # [ 1.7485,  0.5180, -1.2110, -1.3865, -0.6293]

relu = nn.ReLU()

# Without hook:
out = relu(inp)
out.sum().backward()
print(inp.grad) # [1., 1., 0., 0., 0.]

inp.grad.zero_()
# With hook
def grad_hook(mod, grad_in, grad_out):
    # Ignore the computed grad_input
    # Make it look like this is an identity
    return grad_out
relu.register_backward_hook(grad_hook)

out = relu(inp)
out.sum().backward()
print(inp.grad) # [1., 1., 1., 1., 1.]