HELP- FEB20-LONG (THEATRE) Hungarian algorithm implementation

The question can clearly work on Hungarian Algorithm. I have found a python code for its implementation here. But the last part of the code is not optimal. In the final step of Hungarian Algorithm we have to cancel out maximum no. of zeroes with minimum no. of lines. Can anyone help me with implementation of the last part in python code?