Course 4 Week 1 assignment 2, Exercise 1 Keras

Here, we have to use various classes of tf.keras.layers.
One of the class that we use is tf.keras.layers.ZeroPadding2d
Upon searching for few reading materials on this, I found this line of code :
x = ZeroPadding2D(((0, 0), pad_amt))(x) --------- on link : https://www.programcreek.com/python/example/127087/tensorflow.keras.layers.ZeroPadding2D

Now since ZeroPadding2D is a class therefore we can simply call it’s constructor by :slight_smile:
tf.keras.layers.ZeroPadding2D(**Pass the appropriate argument &)
but then in above example it’s also using the bold marked “x”. I don’t understand what that means in Python, can anyone explain?

It calls magic methods in Python
after constructor called, the method call can be called (sorry for lot’s of “call”)
you can google “magic methods”

in current example you link two layers the x that was before you initialize the ZeroPadding
for example:
x = Conv2D(…)(input)
x = ZeroPadding2D(…)(x)
now x is Conv2d - ZeroPadding computation graph with 2 layers

https://rszalski.github.io/magicmethods/

I read through your reference and found that new is called for object instantiation and this function calls init as constructor.
I read through the entire reference but couldn’t find any explaination for the kind of syntax that I said above.
I understood the “logical part” of how something like Conv2D(…)(input) is working but how is magic function related to this or how is any of the fundamental programming constructs of python is related to this?