Pytorch: assigns values to a tensor by index
How to assign values to a Tensor by index like Numpy in python?
In numpy, we can fill values to an array by index:
array = np.zeros((10, 8, 3), dtype=np.float32)
for n in range(10):
    for k in range(4):
        array[n, k, :] = x, y, -2  # x,y are diffrent values in every loop
        array[n, 4 + k, :] = x, y, 0.4

If there is a zeros tensor using torch.zeros, how to fill values to it in Pytorch by the indexes?

Group the values to a tensor and then assign:
import torch

array = torch.zeros((10, 8, 3), dtype=torch.float32)
for n in range(10):
    for k in range(4):
        x, y = 1, -1
        array[n, k, :] = torch.tensor([x, y, -2])  # x,y are diffent values in every loop
        array[n, 4 + k, :] = torch.tensor([x, y, 0.4])

