If i have tensor `A = torch.rand(30,500,50,50)`

what is the smartest and fastest way to normalize each layer (the layers in A.size(1)) to have values between a and b.

The naive way is:

B = torch.zeros(A.size())

```
for b in range(A.size(0)):
for c in range(A.size(1)):
B[b,c,:,:] = ((b-a)*(A[b,c,:,:]-torch.min(A[b,c,:,:]))/(torch.max(A[b,c,:,:])-torch.min(A[b,c,:,:]))) + a
```

But it is super slow…