class_docstr: ## Encoder module
docstr: :param img: is the image tensor with shape `[batch_size, img_channels, img_height, img_width]`
code: def forward(self, img: torch.Tensor):
      """
      :param img: is the image tensor with shape `[batch_size, img_channels, img_height, img_width]`
      """
  
      # Map to `channels` with the initial convolution
      x = self.conv_in(img)
  
      # Top-level blocks
      for down in self.down:
          # ResNet Blocks
          for block in down.block:
              x = block(x)
          # Down-sampling
          x = down.downsample(x)
  
      # Final ResNet blocks with attention
      x = self.mid.block_1(x)
      x = self.mid.attn_1(x)
      x = self.mid.block_2(x)
  
      # Normalize and map to embedding space
      x = self.norm_out(x)
      x = swish(x)
      x = self.conv_out(x)
  
      #
      return x
  
imports: from typing import List
  import torch
  import torch.nn.functional
  from torch import nn
label_desc: Use image node_id 2 for calling the Encoder obj's underlying member method code with example usage: obj.forward(img) and returns: x