I’m trying to create a mask based on an index tensor.

The mask size is [6, 1, 25]

The index size is [6, 1, 12]

First I have an index tensor `indices`

:

```
print(indices)
tensor([[[ 0, 1, 2, 5, 6, 7, 12, 17, 18, 22, 23, 21]],
[[ 2, 3, 4, 7, 8, 9, 15, 16, 20, 21, 22, 13]],
[[ 0, 1, 5, 6, 10, 11, 15, 16, 17, 20, 21, 12]],
[[ 1, 10, 15, 16, 17, 18, 20, 21, 22, 23, 24, 2]],
[[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13]],
[[ 3, 4, 8, 9, 13, 14, 18, 19, 22, 23, 24, 17]]], device='cuda:0')
```

Then I allocate a mask tensor

```
mask = torch.cuda.ByteTensor(6, 1, 25).zero_()
```

Now I want to set only [0, 0, 0], [0, 0, 1], …, [0, 0, 23], [0, 0, 25], etc. in tensor `mask`

to `1`

I have tried:

`mask[indices] = 1`

,

I have also tried adapting solutions given in

to this problem unsuccessfully.

Any help would be appreciated, thank you.