py code works for mlp