hunk.code_window:     'seresnet101':
           _cfg(url='http://data.lip6.fr/cadene/pretrainedmodels/se_resnet101-7e38fcc6.pth'),
       'seresnet152':
           _cfg(url='http://data.lip6.fr/cadene/pretrainedmodels/se_resnet152-d17c99b7.pth'),
       'seresnext50_32x4d':
           _cfg(url='http://data.lip6.fr/cadene/pretrainedmodels/se_resnext50_32x4d-a260b3a4.pth'),
       'seresnext101_32x4d':
           _cfg(url='http://data.lip6.fr/cadene/pretrainedmodels/se_resnext101_32x4d-3b2fe3d8.pth'),
  
hunk.labels: keep keep keep add keep keep keep keep
hunk.after_edit:     'seresnext26_32x4d':
           _cfg(url='https://www.dropbox.com/s/zaeruz2bejcdhh3/seresnext26_32x4d-65ebdb501.pth?dl=1',
                interpolation='bicubic'),
  
hunk.file_path: models/senet.py
hunk.type: add
file: """ PyTorch selectable adaptive pooling
  Adaptive pooling with the ability to select the type of pooling from:
      * 'avg' - Average pooling
      * 'max' - Max pooling
      * 'avgmax' - Sum of average and max pooling re-scaled by 0.5
      * 'avgmaxc' - Concatenation of average and max pooling along feature dim, doubles feature dim
  
  Both a functional and a nn.Module version of the pooling is provided.
  
  Author: Ross Wightman (rwightman)
  """
  import torch
  import torch.nn as nn
  import torch.nn.functional as F
  
  
  def adaptive_pool_feat_mult(pool_type='avg'):
      if pool_type == 'catavgmax':
          return 2
      else:
          return 1
  
  
  def adaptive_avgmax_pool2d(x, output_size=1):
      x_avg = F.adaptive_avg_pool2d(x, output_size)
      x_max = F.adaptive_max_pool2d(x, output_size)
      return 0.5 * (x_avg + x_max)
  
  
  def adaptive_catavgmax_pool2d(x, output_size=1):
      x_avg = F.adaptive_avg_pool2d(x, output_size)
      x_max = F.adaptive_max_pool2d(x, output_size)
      return torch.cat((x_avg, x_max), 1)
  
  
  def select_adaptive_pool2d(x, pool_type='avg', output_size=1):
      """Selectable global pooling function with dynamic input kernel size
      """
      if pool_type == 'avg':
          x = F.adaptive_avg_pool2d(x, output_size)
      elif pool_type == 'avgmax':
          x = adaptive_avgmax_pool2d(x, output_size)
      elif pool_type == 'catavgmax':
          x = adaptive_catavgmax_pool2d(x, output_size)
      elif pool_type == 'max':
          x = F.adaptive_max_pool2d(x, output_size)
      else:
          assert False, 'Invalid pool type: %s' % pool_type
      return x
  
  
  class AdaptiveAvgMaxPool2d(torch.nn.Module):
      def __init__(self, output_size=1):
          super(AdaptiveAvgMaxPool2d, self).__init__()
          self.output_size = output_size
  
      def forward(self, x):
          return adaptive_avgmax_pool2d(x, self.output_size)
  
  
  class AdaptiveCatAvgMaxPool2d(torch.nn.Module):
      def __init__(self, output_size=1):
          super(AdaptiveCatAvgMaxPool2d, self).__init__()
          self.output_size = output_size
  
      def forward(self, x):
          return adaptive_catavgmax_pool2d(x, self.output_size)
  
  
  class SelectAdaptivePool2d(torch.nn.Module):
      """Selectable global pooling layer with dynamic input kernel size
      """
      def __init__(self, output_size=1, pool_type='avg'):
          super(SelectAdaptivePool2d, self).__init__()
          self.output_size = output_size
          self.pool_type = pool_type
          if pool_type == 'avgmax':
              self.pool = AdaptiveAvgMaxPool2d(output_size)
          elif pool_type == 'catavgmax':
              self.pool = AdaptiveCatAvgMaxPool2d(output_size)
          elif pool_type == 'max':
              self.pool = nn.AdaptiveMaxPool2d(output_size)
          else:
              if pool_type != 'avg':
                  print('Invalid pool type %s specified. Defaulting to average pooling.' % pool_type)
              self.pool = nn.AdaptiveAvgPool2d(output_size)
  
      def forward(self, x):
          return self.pool(x)
  
      def feat_mult(self):
          return adaptive_pool_feat_mult(self.pool_type)
  
      def __repr__(self):
          return self.__class__.__name__ + ' (' \
                 + 'output_size=' + str(self.output_size) \
                 + ', pool_type=' + self.pool_type + ')'
  