OOP structure of Pytorch
I have started learning OOP for implementing my DL models in Pytorch. Where can I find the OOP structure of Pytorch. By structure I mean the class structures (i.e. inheritance structure of classes like Sequential container). I know Module class is base for most structures.
Also I was exploring Pytorch on github and I am confused how import statements in Pytorch works. For example, the Module class is defined in torch/nn/modules/module.py but we only import torch.nn and write nn.Module to represent the Module class. Should it not be nn.modules.module.Module by the way it is stored on github?
# Example of using Sequential
model = nn.Sequential(
nn.Conv2d(1,20,5),
nn.ReLU(),
nn.Conv2d(20,64,5),
nn.ReLU()
)

Sequential class in defined in /torch/nn/modules/container.py file but we just use nn.Sequential here?
Also I didn't find __call__ method in Sequential class then how the above code calling the class as a function.

In python what you import inside a file becomes part of the file. So when you import  nn.modules.module.Module in __init__.py(which is inside nn folder), it becomes part of the nn module.
Here I will give a quick example.
Let's see we have three files file1.py, file2.py and file3.py, and we have a variable var = 10 defined in file1.py.  If we have imported this variable inside file2.py, file3.py can directly import the variable from file2.py.
file1.py
var = 10

file2.py
from file1 import var

file3.py
from file2 import var
print(var)
# Prints 10

Now let's go back to your question. As you said the Module class is defined inside nn.modules.module.Module. But this class has been imported first inside nn/modules/__init__.py and then it was imported inside  nn/__init__.py. That is why you can import Module class from nn package.
But importing will not change the type of objects you will create from the class.
from torch.nn import Module

module = Module()

print(type(module)) # torch.nn.modules.module.Module


