I just remembered I had seen the PyTorch internals 62 a while ago. This article explains how to add a new data type in CPython and integrate it into PyTorch.
For basic data types such as Float, the THGenerateFloatType.h header file has a line that looks like this:
#define real float

where all instances of real in Tensor.cpp will be replaced by float when the code is automatically generated.
Can I define my own data type using something like this:
typedef struct {
    PyObject_HEAD
    int first;
    int second;
} PyMyObject;


and creating a new header file that has a line that looks like this:
#define real PyMyObject

?