Truncate a tensor to given shape

Hi there.

I have a tensor, say v, of shape, say (10, 3, 50,25,12)

I have a variable shape, that contains, say (10, 2, 13, 18, 12)

Is there a convenient way to “truncate” v so that its shape becomes shape ?

thanks !

ok, got it:

v[[slice(k) for k in shape]]