@albanD Hello, and thanks for the comment. calling ranked_tensor[idx] at multiple places was indeed the problem. I would not have guessed that indexing a variable without assignment creates a new variable.