Pytorch select tensor
I want to know if Pytorch have a slice function (same as tf). In particular, I want to select the orange color rows. 



You can use slicing as in numpy. 
See below

import torch
A = torch.rand((3,5,500))
first_three_rows = A[:, :3, :]


However to get different slices as you asked in the question, you can do

import torch
A = torch.rand((3,5,500))
indices = [2,4,5]
result = torch.cat([A[idx, :index, :] for idx, index in enumerate(indices)] , dim=0)

