Indexing over the last axis when you don’t know the rank in advance December 15, 2023 by Tarik b = a[..., -k:] This is mentioned in the docs.