Thank you driazati and G.M, I have also found another solution in Github issues in the meantime.

  
      github.com/pytorch/vision
  
  
    
  
    
  

  
    
      make shufflenet and resnet scriptable
    

    
      pytorch:master ← eellison:shufflenet
    

    
      
        opened 
        
          
        
        Aug 28, 2019
      
      

      
        
          
          eellison
        
      

      
        
          +6
          -2
        
      
    

  

  
  
    
    
  
  



  
      github.com/pytorch/pytorch
  
  
    
  
	  
  

  
    
      TorchScript doesn't handle submodule being None 5
    

    
      
        opened 
        
          
        
        Sep 12, 2019
      
      

        
          closed 
        
          
        
        Jan 27, 2020
      
        

      
        
          
          dzhulgakov
        
      
    
  



  🐛 Bug
If one of the submodules is None, TorchScript doesn't recognize it as an attribute, unless explicitly specified in __constants__ lists.
Obviously,...



    jit
    jit-backlog