Two issues:
First, the logging statement
logger(f"Processing Z({m},{n}) = {z[m][n].payload}")
seems misplaced, the variable n is not defined yet at that point.
Second, tensor Z is not being filled with zeroes. The "hack" to fill in entries of Z does not seem to work anymore.