I think it is not exactly as in Python, because in Python it may be gced or may be not but it looks like in c++ it is guaranteed(All temporary objects are destroyed as the last step in evaluating the full-expression that (lexically) contains the point where they were created) to be destroyed. So, is the object returned by cpu() method allocated in the stack? I assume if it was dynamically created, some sort of memory leak would have occurred.
Still, it feels like created cpu tensor should contain a week reference to the created pointer to prevent it from deallocation and this would allow that one-liner.