Can you pass a variable to a data member in Python as done in Pytorch?
Here is the sample code from the nn.Module of pytorch documentation:

class Model(nn.Module):
    def __init__(self):
        super(Model, self).__init__()
        self.conv1 = nn.Conv2d(1, 20, 5)
        self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
       x = F.relu(self.conv1(x))
       return F.relu(self.conv2(x))


Here, we are passing x to self.conv1() in the forward function.
However, self.conv1 is a variable as can been from this line self.conv1 = nn.Conv2d(1, 20, 5) in the __init__ function.

How is this possible?

Forward passes of anything in pytorch, layer or network, is done in functional way var(x). This is made in python with overwriting __call__() built-in. Try it yourself. Make a class, overwrite __call__() and use it like function.
