Solved by InnovArul in post #2 
              
              
                .modules() is a function defined under class nn.Module. 

You need to rename the variable self.modules as it is conflicting with this function.