class_docstr: SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers
code: def __init__(
      self,
      input_spec: FeatureMapsSpecification,
      num_classes: int,
      embedding_dim: int,
      with_supervision: bool,
      output_name: Optional[str],
      dropout_rate: float = 0.0,
      activation: str = ACT_GELU,
  ):
      super().__init__(input_spec)
  
      self.num_classes = num_classes
      self.output_name = output_name
      self.with_supervision = with_supervision
  
      (
          c1_in_channels,
          c2_in_channels,
          c3_in_channels,
          c4_in_channels,
      ) = input_spec.channels
  
      self.linear_c4 = nn.Conv2d(
          c4_in_channels, embedding_dim, kernel_size=1
      )
      self.linear_c3 = nn.Conv2d(
          c3_in_channels, embedding_dim, kernel_size=1
      )
      self.linear_c2 = nn.Conv2d(
          c2_in_channels, embedding_dim, kernel_size=1
      )
      self.linear_c1 = nn.Conv2d(
          c1_in_channels, embedding_dim, kernel_size=1
      )
  
      self.linear_fuse = nn.Sequential(
          nn.Conv2d(
              embedding_dim * 4,
              embedding_dim,
              kernel_size=1,
              bias=False,
          ),
          nn.BatchNorm2d(embedding_dim),
          instantiate_activation_block(activation, inplace=True),
      )
  
      self.dropout = nn.Dropout2d(dropout_rate, inplace=False)
      self.final = nn.Conv2d(embedding_dim, num_classes, kernel_size=1)
  
      if self.with_supervision:
          self.supervision_c4 = nn.Conv2d(
              embedding_dim, num_classes, kernel_size=1
          )
          self.supervision_c3 = nn.Conv2d(
              embedding_dim, num_classes, kernel_size=1
          )
          self.supervision_c2 = nn.Conv2d(
              embedding_dim, num_classes, kernel_size=1
          )
          self.supervision_c1 = nn.Conv2d(
              embedding_dim, num_classes, kernel_size=1
          )
      else:
          self.supervision_c4 = None
          self.supervision_c3 = None
          self.supervision_c2 = None
          self.supervision_c1 = None
  
file_path: pytorch-toolbelt/pytorch_toolbelt/modules/heads/segformer_head.py
imports: from typing import List, Optional
  import torch
  import torch.nn
  from torch import Tensor
  from pytorch_toolbelt.datasets import name_for_stride
  from pytorch_toolbelt.modules import instantiate_activation_block, ACT_GELU
  from pytorch_toolbelt.modules.interfaces import AbstractHead, FeatureMapsSpecification
label_desc: Use image node_id 1 to create a new SegFormerHead object from inherited base classes: AbstractHead with example: obj = SegFormerHead(input_spec, num_classes, embedding_dim, with_supervision, output_name, dropout_rate, activation)