It works. Thanks for this! One last question: is there a way to simultaneously slice along all dimensions of a tensor. Say, for example, I have a tensor inp with shape [16, 1, 125, 256]. I then have two lists (this is a simple example)
begin = [0, 0, 0, 0]
end = [16, 1, 125, 256]
that specify the beginning and end indices to slice, respectively. From this, I perform slicing as
out = inp[begin[0]:end[0], begin[1]:end[1], begin[2]:end[2], begin[3]:end[3]]
How do I do this with any tensor with a variable number of dimensions?