title: Why in Keras subclassing API, the call method is never called and as an alternative the input is passed by calling the object of this class?
body: <p>When creating a model using Keras subclassing API, we write a custom model class and define a function named <code>call(self, x)</code>(mostly to write the forward pass) which expects an input. However, this method is never called and instead of passing the input to <code>call</code>, it is passed to the object of this class as <code>model(images)</code>.</p>
  
  <p>How are we able to call this <code>model</code> object and pass values when we haven't implemented Python special method, <code>__call__</code> in the class</p>
  
  <pre><code>class MyModel(Model):
    def __init__(self):
      super(MyModel, self).__init__()
      self.conv1 = Conv2D(32, 3, activation='relu')
      self.flatten = Flatten()
      self.d1 = Dense(128, activation='relu')
      self.d2 = Dense(10, activation='softmax')
  
    def call(self, x):
      x = self.conv1(x)
      x = self.flatten(x)
      x = self.d1(x)
      return self.d2(x)
  
  # Create an instance of the model
  model = MyModel()
  </code></pre>
  
  <p>Use tf.GradientTape to train the model:</p>
  
  <pre><code>@tf.function
  def train_step(images, labels):
    with tf.GradientTape() as tape:
      predictions = model(images)
      loss = loss_object(labels, predictions)
    gradients = tape.gradient(loss, model.trainable_variables)
    optimizer.apply_gradients(zip(gradients, model.trainable_variables))
  
    train_loss(loss)
    train_accuracy(labels, predictions)
  </code></pre>
  
  <p><strong>Shouldn't the input be passed like below:</strong></p>
  
  <pre><code>model = MyModel()
  model.call(images)
  </code></pre>