code: def __init__(self, config: SwiftFormerConfig) -> None:
      super().__init__()
      self.config = config
  
      embed_dims = config.embed_dims
      downsamples = config.downsamples
      layer_depths = config.depths
  
      # Transformer model
      network = []
      for i in range(len(layer_depths)):
          stage = SwiftFormerStage(config=config, index=i)
          network.append(stage)
          if i >= len(layer_depths) - 1:
              break
          if downsamples[i] or embed_dims[i] != embed_dims[i + 1]:
              # downsampling between two stages
              network.append(SwiftFormerEmbeddings(config, index=i))
      self.network = nn.ModuleList(network)
  
      self.gradient_checkpointing = False
  
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 1 to create a new SwiftFormerEncoder object from inherited base classes: nn with example: obj = SwiftFormerEncoder(config)