how target[y == l] = label work is labeling make_blobs dataset in pytorch tutorial?
I am learning PyTorch with this blog: [PyTorch Introduction to Neural Network] (https://medium.com/biaslyai/pytorch-introduction-to-neural-network-feedforward-neural-network-model-e7231cff47cb)
 I found this piece of code confusing:

from sklearn.datasets import make_blobs
def blob_label(y, label, loc): # assign labels
    target = numpy.copy(y)
    for l in loc:
        target[y == l] = label
    return target
x_train, y_train = make_blobs(n_samples=40, n_features=2, cluster_std=1.5, shuffle=True)
x_train = torch.FloatTensor(x_train)
y_train = torch.FloatTensor(blob_label(y_train, 0, [0]))
y_train = torch.FloatTensor(blob_label(y_train, 1, [1,2,3]))
x_test, y_test = make_blobs(n_samples=10, n_features=2, cluster_std=1.5, shuffle=True)
x_test = torch.FloatTensor(x_test)
y_test = torch.FloatTensor(blob_label(y_test, 0, [0]))
y_test = torch.FloatTensor(blob_label(y_test, 1, [1,2,3]))


how exactly is target[y == l] = label working in here? 
how this line of code assigns 1s and 0s to the data?
Thanks!

It's Boolean or “mask” index arrays see doc for more

&gt;&gt;&gt; y = torch.arange(9).reshape(3,3)
&gt;&gt;&gt; y
tensor([[0, 1, 2],
        [3, 4, 5],
        [6, 7, 8]])
&gt;&gt;&gt; target = np.copy(y)


so, target[y == l] = label
y == l give us boolean array like (if l = 0)

&gt;&gt;&gt; y == 0
tensor([[ True, False, False],
        [False, False, False],
        [False, False, False]])


and we can access and assign value using boolean array y == 0

&gt;&gt;&gt; target[y == 0]
array([0], dtype=int64)

&gt;&gt;&gt; target[y == 0] = 999
&gt;&gt;&gt; target
array([[999,   1,   2],
       [  3,   4,   5],
       [  6,   7,   8]], dtype=int64)

