The main problem lies in the repeated definition of the fitness() function. The last definition of the fitness() function in the general.py in the utils folder can be deleted. In the general.py header file, you can find that the metrics in the folder are referenced. py, however metrics.py has defined the fitness() function.