Well in cpp, you have a single metaclass and then for each tensor type, set the parent type to be the metaclass.
This metaclass is here to make this isinstance magic work using this function 3 that is called when you call isinstance because of this 2.
Hope this helps