What kind of network need to rewrite the backward function?

Does I need to rewrite the backward function which a part of the forward net like this?

pool = []
for i in range(n):
    pool.append(F.adaptive_avg_pool2d(img, 7))
pool = torch.cat(pool, 0)

normally you don’t need to write backward at all unless you are writing a custom autograd function.