How to call method without method name in python

  python, pytorch
class LinearRegression(nn.Module):
def __init__(self,input_size,output_size):
    # super function. It inherits from nn.Module and we can access everythink in nn.Module
    # Linear function.
    self.linear = nn.Linear(input_dim,output_dim)

def forward(self,x):
    return self.linear(x)

input_dim = 1
output_dim = 1
model = LinearRegression(input_dim,output_dim)

In this code block when I want to call forward method in model object I can call 2 different ways

The first way

results = model.forward(car_price_tensor)

Second way

results = model(car_price_tensor)

And I try the second way on a different class and object it doesnt work. How it possible?

Source: Python Questions