code: def __init__(
      self,
      in_channels=3,
      output_stride=16,
      backbone="resnet101",
      pretrained=True,
  ):
      super(ResNet, self).__init__()
      model = getattr(models, backbone)(pretrained)
      if not pretrained or in_channels != 3:
          self.initial = nn.Sequential(
              nn.Conv2d(
                  in_channels, 64, 7, stride=2, padding=3, bias=False
              ),
              nn.BatchNorm2d(64),
              nn.ReLU(inplace=True),
              nn.MaxPool2d(kernel_size=3, stride=2, padding=1),
          )
          initialize_weights(self.initial)
      else:
          self.initial = nn.Sequential(*list(model.children())[:4])
  
      self.layer1 = model.layer1
      self.layer2 = model.layer2
      self.layer3 = model.layer3
      self.layer4 = model.layer4
  
      if output_stride == 16:
          s3, s4, d3, d4 = (2, 1, 1, 2)
      elif output_stride == 8:
          s3, s4, d3, d4 = (1, 1, 2, 4)
  
      if output_stride == 8:
          for n, m in self.layer3.named_modules():
              if "conv1" in n and backbone in ("resnet34", "resnet18"):
                  m.dilation, m.padding, m.stride = (
                      (d3, d3),
                      (d3, d3),
                      (s3, s3),
                  )
              elif "conv2" in n:
                  m.dilation, m.padding, m.stride = (
                      (d3, d3),
                      (d3, d3),
                      (s3, s3),
                  )
              elif "downsample.0" in n:
                  m.stride = (s3, s3)
  
      for n, m in self.layer4.named_modules():
          if "conv1" in n and backbone in ("resnet34", "resnet18"):
              m.dilation, m.padding, m.stride = (
                  (d4, d4),
                  (d4, d4),
                  (s4, s4),
              )
          elif "conv2" in n:
              m.dilation, m.padding, m.stride = (
                  (d4, d4),
                  (d4, d4),
                  (s4, s4),
              )
          elif "downsample.0" in n:
              m.stride = (s4, s4)
  
imports: import torch
  import logging
  import torch.nn
  import torch.nn.functional
  from torchvision import models
  from itertools import chain
  import numpy
  from collections import OrderedDict
label_desc: Use image node_id 1 to create a new ResNet object from inherited base classes: nn with example: obj = ResNet(in_channels, output_stride, backbone, pretrained)