Hi Nauryzbay!



 MrPositron:

So that I will get the following result:
A = [
    [101, 102, 3, 4, 5, 6],
    [102, 3, 4, 105, 6, 1],
    [3, 104, 5, 6, 101, 2],
]



You may use scatter_add_() (with pytorch tensors) for this:
>>> import torch
>>> torch.__version__
'1.9.0'
>>> A = torch.tensor ([
...     [1, 2, 3, 4, 5, 6],
...     [2, 3, 4, 5, 6, 1],
...     [3, 4, 5, 6, 1, 2],
... ])
>>> B = torch.tensor ([
...     [0, 1],
...     [0, 3],
...     [1, 4],
... ])
>>> A.scatter_add_ (1, B, torch.tensor ([100]).expand (B.shape))
tensor([[101, 102,   3,   4,   5,   6],
        [102,   3,   4, 105,   6,   1],
        [  3, 104,   5,   6, 101,   2]])
>>> A
tensor([[101, 102,   3,   4,   5,   6],
        [102,   3,   4, 105,   6,   1],
        [  3, 104,   5,   6, 101,   2]])

Best.
K. Frank