Hi,
I also run into this bug when I am trying to realize Layer-wise Relevance Propagation.
Concretly, I rewrite backward function for each layer in Net, for example
class Linear(torch.autograd.Function):

    def forward(self, input, weight, bias):
        self.eps = 1e-16
        self.Z = weight.t()[None, :, :] * input[:, :, None]
        self.Zs = self.Z.sum(dim=1, keepdim=True)
        if bias is not None:
            self.Zs += bias[None, None, :]
        return self.Zs.squeeze(dim=1)

    def backward(self,R):
        print('linear')
        return (R[:, None, :] * self.Z / (self.Zs + (2 * (self.Zs >= 0) - 1) * self.eps)).sum(dim=2)


and run
model.readout.backward(out)

Unfortunately, it reported as follows
Traceback (most recent call last):

  File "G:\Explainer\_Geo_Exp_inter\infectionLRP.py", line 117, in <module>
    print(model.readout.backward(out))

  File "D:\Anaconda3\lib\site-packages\torch\tensor.py", line 195, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph)

  File "D:\Anaconda3\lib\site-packages\torch\autograd\__init__.py", line 98, in backward
    allow_unreachable=True)  # allow_unreachable flag

RuntimeError: could not compute gradients for some functions

It has confused me for a few days and I don’t really kown what cause it and how to fix it.
Yingxin Wu