Cverlpeng:

for i in range(dt_out.shape[0]):
    for j in range(dt_out.shape[1]): 
        dt_out[i,j,:,:] = torch.div(torch.clamp(dt_out[i,j,:,:], min, max), max)



This is bad! use the non-inplace dt_out = x.clamp(min, max) / max instead.
Best regards
Thomas