class_docstr: SwiftFormer Encoder Block for SwiftFormer. It consists of (1) Local representation module, (2)
  SwiftFormerEfficientAdditiveAttention, and (3) MLP block.
  
  Input: tensor of shape `[batch_size, channels, height, width]`
  
  Output: tensor of shape `[batch_size, channels,height, width]`
class_docstr_tok: ["SwiftFormer","Encoder","Block","for","SwiftFormer",".","It","consists","of","(","1",")","Local","representation","module",",","(","2",")","SwiftFormerEfficientAdditiveAttention",",","and","(","3",")","MLP","block",".","Input",":","tensor","of","shape","`","[","batch_size",",","channels",",","height",",","width","]","`","Output",":","tensor","of","shape","`","[","batch_size",",","channels",",","height",",","width","]","`"]
code: def forward(self, x):
      x = self.local_representation(x)
      batch_size, channels, height, width = x.shape
      if self.use_layer_scale:
          x = x + self.drop_path(
              self.layer_scale_1
              * self.attn(
                  x.permute(0, 2, 3, 1).reshape(
                      batch_size, height * width, channels
                  )
              )
              .reshape(batch_size, height, width, channels)
              .permute(0, 3, 1, 2)
          )
          x = x + self.drop_path(self.layer_scale_2 * self.linear(x))
  
      else:
          x = x + self.drop_path(
              self.attn(
                  x.permute(0, 2, 3, 1).reshape(
                      batch_size, height * width, channels
                  )
              )
              .reshape(batch_size, height, width, channels)
              .permute(0, 3, 1, 2)
          )
          x = x + self.drop_path(self.linear(x))
      return x
  
imports: import collections.abc
  from typing import Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
  from ...activations import ACT2CLS
  from ...modeling_outputs import BaseModelOutputWithNoAttention, ImageClassifierOutputWithNoAttention
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
  from .configuration_swiftformer import SwiftFormerConfig
label_desc: Use image node_id 2 for calling the SwiftFormerEncoderBlock obj's underlying member method code with example usage: obj.forward(x) and returns: x