title: PyTorch get all layers of model
body: <p>What's the easiest way to take a pytorch model and get a list of all the layers without any <code>nn.Sequence</code> groupings? For example, a better way to do this?</p>
  <pre><code>import pretrainedmodels
  
  def unwrap_model(model):
      for i in children(model):
          if isinstance(i, nn.Sequential): unwrap_model(i)
          else: l.append(i)
  
  model = pretrainedmodels.__dict__['xception'](num_classes=1000, pretrained='imagenet')
  l = []
  unwrap_model(model)            
              
  print(l)
      
  </code></pre>