Python uses lexical scoping so that the closure will use the name and scope of the passed variable i.
To fix this issue, you could pass i to the lambda as:
conv_layer.weight.register_hook(lambda grad, i=i: dummy(i))