class_docstr: A ResNet class that is similar to torchvision's but contains the following changes:
  - There are now 3 "stem" convolutions as opposed to 1, with an average pool instead of a max pool.
  - Performs anti-aliasing strided convolutions, where an avgpool is prepended to convolutions with stride > 1
  - The final pooling layer is a QKV attention instead of an average pool
class_docstr_tok: ["A","ResNet","class","that","is","similar","to","torchvision","'s","but","contains","the","following","changes",":","-","There","are","now","3","``","stem","''","convolutions","as","opposed","to","1",",","with","an","average","pool","instead","of","a","max","pool",".","-","Performs","anti-aliasing","strided","convolutions",",","where","an","avgpool","is","prepended","to","convolutions","with","stride",">","1","-","The","final","pooling","layer","is","a","QKV","attention","instead","of","an","average","pool"]
code: def __init__(
      self, layers, output_dim, heads, input_resolution=224, width=64
  ):
      super().__init__()
      self.output_dim = output_dim
      self.input_resolution = input_resolution
  
      # the 3-layer stem
      self.conv1 = nn.Conv2D(
          3,
          width // 2,
          kernel_size=3,
          stride=2,
          padding=1,
          bias_attr=False,
      )
      self.bn1 = nn.BatchNorm2D(width // 2)
      self.conv2 = nn.Conv2D(
          width // 2,
          width // 2,
          kernel_size=3,
          padding=1,
          bias_attr=False,
      )
      self.bn2 = nn.BatchNorm2D(width // 2)
      self.conv3 = nn.Conv2D(
          width // 2, width, kernel_size=3, padding=1, bias_attr=False
      )
      self.bn3 = nn.BatchNorm2D(width)
      self.avgpool = nn.AvgPool2D(2)
      self.relu = nn.ReLU()
  
      # residual layers
      self._inplanes = (
          width  # this is a *mutable* variable used during construction
      )
      self.layer1 = self._make_layer(width, layers[0])
      self.layer2 = self._make_layer(width * 2, layers[1], stride=2)
      self.layer3 = self._make_layer(width * 4, layers[2], stride=2)
      self.layer4 = self._make_layer(width * 8, layers[3], stride=2)
  
      embed_dim = width * 32  # the ResNet feature dimension
      self.attnpool = AttentionPool2d(
          input_resolution // 32, embed_dim, heads, output_dim
      )
  
imports: from typing import Tuple
  from typing import Union
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddle import nn
  from .layers import AttentionPool2d
  from .layers import Bottleneck
  from .layers import MultiHeadAttention
  from .layers import ResidualAttentionBlock
label_desc: Use image node_id 1 to create a new ModifiedResNet object from inherited base classes: nn with example: obj = ModifiedResNet(layers, output_dim, heads, input_resolution, width)