I was looking the implementation of ResNet deep learning architecture in PyTorch from git-hub. At line 167, inside the initializer of another class definition which defines ResNet and is also named ResNet, I saw the code below:
block: Type[Union[BasicBlock, Bottleneck]],
BasicBlock and Bottleneck are two classes defined before line 167. When I looked up for what Type and Union do, as far as I understood it says that block could be either of BasicBlock or Bottleneck. block itself was passed to a function named _make_layer which is defined at line 223 and is a method of ResNet class and I wonder how _make_layer know how the passed argument is either BasicBlock or Bottleneck?
When someone is making an instance of ResNet class, should they pass an object of BasicBlock or Bottleneck? and is this how _make_layer knows what it got as its argument? Then why do we need to use Union?
 
     
    