This should work:
x = random_score_map.clone()
s = (x**2).sum(4, keepdims=True)
n = torch.sqrt(s)
x /= n

print(torch.allclose(x, score_map))
> True

Note that you should avoid for loops where possible and try to use vectorized code instead.