The method to root the L40M5-5AIN differs slightly depending on whether you are running an older firmware or a newer OTA (Over The Air) update.
You will need to downgrade your firmware to a vulnerable version (e.g., V6.0.4.1588). How to root XIAOMI Mi TV 4A 40 L40M5-5AIN
Bootloader is locked on Mi TVs, but if somehow unlocked (not officially possible), you could patch boot with Magisk and flash via fastboot . The method to root the L40M5-5AIN differs slightly
To root the Xiaomi Mi TV 4A 40" (L40M5-5AIN) Go to product viewer dialog for this item. How to root XIAOMI Mi TV 4A 40 L40M5-5AIN