There was a problem grading your submission. Details: name 'gen' is not defined

Week 4: Handling Complex Images - Happy or Sad Dataset

Model reached at accuracy working very well but after submitting its give error like:
There was a problem grading your submission. Details:
name ‘gen’ is not defined

Looks like you are using global variables within your graded functions. You should instead use the parameters defined for each function since the grader will wipe out all global scope.