code: def modify_densenets(model):
      # Modify attributs
      model.last_linear = model.classifier
      del model.classifier
  
      def logits(self, features):
          x = F.relu(features, inplace=True)
          x = F.avg_pool2d(x, kernel_size=7, stride=1)
          x = x.view(x.size(0), -1)
          x = self.last_linear(x)
          return x
  
      def forward(self, input):
          x = self.features(input)
          x = self.logits(x)
          return x
  
      # Modify methods
      model.logits = types.MethodType(logits, model)
      model.forward = types.MethodType(forward, model)
      return model
  
imports: from __future__ import print_function, division, absolute_import
  import torchvision.models
  import torch.utils.model_zoo
  import torch.nn.functional
  import types
  import re
label_desc: Use image node_id 5 for calling a global function with example usage: modify_densenets(model) and returns: model, x, x