numpy as well as PyTorch will both fail with a shape mismatch error so you would need to unsqueeze the mask tensor:
weights_x = torch.zeros([32, 1, 5, 5])
weights_y = torch.ones([32, 1, 5, 5])
mask= torch.tensor([False, True, False, True, True, False, False, True, True, True, False, True, False, True, True, True, False, True, True, False, False, True, False, False, False, False, True, False, False, False, True, True])

np.where(mask, weights_x, weights_y) # fails
> ValueError: operands could not be broadcast together with shapes (32,) (32,1,5,5) (32,1,5,5) 

torch.where(mask == True, weights_x, weights_y) # fails
> RuntimeError: The size of tensor a (32) must match the size of tensor b (5) at non-singleton dimension 3

# works
arr = np.where(mask[:, None, None, None], weights_x, weights_y)
out = torch.where(mask[:, None, None, None], weights_x, weights_y)

print((arr == out.numpy()).all())
> True