Did you go through all the threads related to the masked_Accuracy already discussed, read through @arvyzukai response, most of the answer will resolve by reading his comments.
There are almost 4-5 threads about this, also I am sharing one more thread by @lucas.coutinho which I suspect you have the same issue as per your output
Go through them all, use the search engine.
Let me know if you are not able to understand any of those.
Understand that a value shows Nan when one of your recalled code is getting divided by zero which gets you infinity or -infinity.
NaN represents missing or undefined data in Python. It is typically encountered while performing mathematical operations that result in an undefined or nonsensical value. NaN is a floating-point value represented by the float(‘nan’) object in Python.
So go through your codes again and checked which might be causing this issue.
Keep learning and debugging!
All the best!!
Regards
DP