Copying data from one pytorch tensor to another using bit masking

import torch
a = torch.zeros(5)
b = torch.tensor(tuple((0,1,0,1,0)),dtype=torch.uint8)
c= torch.tensor([7.,9.])
print(a[b].size())
a[b]=c
print(a)

torch.Size([2])
tensor([0., 7., 0., 9., 0.])

I am struggling to understand how this works. I initially thought the above code was using Fancy indexing but I realised that values from c tensors are getting copied corresponding to the indices marked 1. Also, if I don’t specify dtype of b as uint8 then the above code does not work. Can someone please explain me the mechanism of the above code.

The link below explains this behaviour
http://www.math.buffalo.edu/~badzioch/MTH337/PT/PT-boolean_numpy_arrays/PT-boolean_numpy_arrays.html