Appending different 1D tensors to 3rd dimension of 3D tensor

def to_rnn_embed_tensor(tensor: Tensor, cond: list, letter_count=LETTERS_COUNT, cond_to_tensor_func = embed_line_to_tensor) → list:
input_sz, batch_sz = tensor.shape
ret = torch.zeros(input_sz, batch_sz, letter_count)
for i in range(input_sz):
for j in range(batch_sz):
cond_j = cond[j]
cond_tensor = cond_to_tensor_func(cond_j)
ret[i, j, int(tensor[i, j])] = 1
return ret

So I have a list of strings that get converted to tensors that are 1x7 that I’m trying to append to third dimension for a tensor that’s going into a RNN. So ret should be input_sz x batch_sz x letter_count + 7. The issue is that the tensor that gets appended to the third dimension at j should correlate to the jth index in cond list.

Essentially cond_tensor should be appended to ret[i,j] for all j