Hi,
In PyTorch, every model/layer can be defined by extending nn.Module class.
For instance, you can see layers like nn.Linear or nn.Conv2d. When you define a new model, you need to follow same pattern which will be based on nn.Module. This leads to cases where we can have complete models such as resnet, vgg, etc (you can find available models here 2 and their source code 2).
Here is an example:
Let’s say you have 3 models called Net1, Net2 and Net3. Now we want to have a model Combined that uses all three models in it.
class Combined(nn.Module):
  def __init__(self, # your args such as num classes):
    super(Combined, self).__init__()
    self.model1 = Net1()
    self.model2 = Net2()
    self.model3 = Net3()

  def forward(self, x):
    model1_output = self.model1(x) 
    # do your calc with model1_output 
    model2_output = self.model2(model1_output)  # or you can pass `x` 
    # do your calc with model2_output 
    model3_output = self.model3(x)  # or you can pass `x` or `model1_output`, etc
    # do your calc with model1_output 
    return model3_output  # or anything you want as the final output of your `Combined` model



Bests