There are mainly two types of custom ROMs for any Android device. You need to flash them on your phone using custom recovery such as TWRP.They are based on the factory ROM which came pre-installed on your device. In case of Xiaomi devices, developers take the stock China Stable/Beta MIUI ROMs as base, perform modifications and tweaking and then re-pack it. Examples of stock based MIUI ROMs.They are typically based on either AOSP or LineageOS code. They can either be ported from similar devices or built using the kernel source code of a particular device. Xiaomi has not yet released kernel source code for Mi Max 2. Kernel source codes are needed for relatively stable and bug-free experience on custom ROMs. Examples of some popular custom ROMsA) AOSP based ROMsB) LineageOS based ROMs