def __init__(
        self,
        dim: int,
        num_heads: int,
        mlp_ratio: float = 4.0,
        qkv_bias: bool = True,
        norm_layer: type[Module] = nn.LayerNorm,
        act_layer: type[Module] = nn.GELU,
        use_rel_pos: bool = False,
        rel_pos_zero_init: bool = True,
        window_size: int = 0,
        input_size: Optional[tuple[int, int]] = None,
    ) -> None:
        """Construct transformer block.

        Args:
        dim: Number of input channels.
        num_heads: Number of attention heads in each ViT block.
        mlp_ratio: Ratio of mlp hidden dim to embedding dim.
        qkv_bias: If True, add a learnable bias to query, key, value.
        norm_layer: Normalization layer.
        act_layer: Activation layer.
        use_rel_pos: If True, add relative positional embeddings to the attention map.
        rel_pos_zero_init: If True, zero initialize relative positional parameters.
        window_size: Window size for window attention blocks. If it equals 0, then use global attention.
        input_size: Input resolution for calculating the relative positional parameter size.

        """
        super().__init__()
        self.norm1 = norm_layer(dim)
        self.attn = Attention(
            dim,
            num_heads=num_heads,
            qkv_bias=qkv_bias,
            use_rel_pos=use_rel_pos,
            rel_pos_zero_init=rel_pos_zero_init,
            input_size=input_size if window_size == 0 else (window_size, window_size),
        )

        self.norm2 = norm_layer(dim)
        self.mlp = MLPBlock(embedding_dim=dim, mlp_dim=int(dim * mlp_ratio), act=act_layer)

        self.window_size = window_size
Construct transformer block.

        Args:
        dim: Number of input channels.
        num_heads: Number of attention heads in each ViT block.
        mlp_ratio: Ratio of mlp hidden dim to embedding dim.
        qkv_bias: If True, add a learnable bias to query, key, value.
        norm_layer: Normalization layer.
        act_layer: Activation layer.
        use_rel_pos: If True, add relative positional embeddings to the attention map.
        rel_pos_zero_init: If True, zero initialize relative positional parameters.
        window_size: Window size for window attention blocks. If it equals 0, then use global attention.
        input_size: Input resolution for calculating the relative positional parameter size.

        
kornia/contrib/models/sam/architecture/image_encoder.py