Your code isn’t formatted correctly (you can post code snippets by wrapping them into three backticks ```), but based on the error message and the current posted code, I guess that the forward method might be defined inside the __init__ method.
Could you check it and if that’s the case correct the indentation?