Your indentation is wrong, so the def discriminator(…) is local to __init__ rather than in the discriminator class.
Some of the code sources might not be quite au courant (like using Variable…).
Best regards
Thomas