When I tried to print the output type by type(output) inside the get_activation function, there seems to be output with type tuple at variable intervals. I am not sure if it is ok to ignore them for now but does it make sense to unwrap wherever you have output as type tuple and then detach it like:
out1, out2 = output
activation[name] = out1.detach()
activation[name] = out2.detach()