class_docstr: This corresponds to the Block class in the original implementation.
class_docstr_tok: ["This","corresponds","to","the","Block","class","in","the","original","implementation","."]
code: def __init__(
      self,
      config: VitDetConfig,
      drop_path_rate: float = 0,
      window_size: int = 0,
      use_residual_block: bool = False,
  ) -> None:
      super().__init__()
  
      dim = config.hidden_size
      input_size = (
          config.image_size // config.patch_size,
          config.image_size // config.patch_size,
      )
  
      self.norm1 = nn.LayerNorm(dim, eps=config.layer_norm_eps)
      self.attention = VitDetAttention(
          config,
          input_size=input_size
          if window_size == 0
          else (window_size, window_size),
      )
  
      self.drop_path = (
          VitDetDropPath(drop_path_rate)
          if drop_path_rate > 0.0
          else nn.Identity()
      )
      self.norm2 = nn.LayerNorm(dim, eps=config.layer_norm_eps)
      self.mlp = VitDetMlp(
          config=config,
          in_features=dim,
          hidden_features=int(dim * config.mlp_ratio),
      )
  
      self.window_size = window_size
  
      self.use_residual_block = use_residual_block
      if self.use_residual_block:
          # Use a residual block with bottleneck channel as dim // 2
          self.residual = VitDetResBottleneckBlock(
              config=config,
              in_channels=dim,
              out_channels=dim,
              bottleneck_channels=dim // 2,
          )
  
imports: import collections.abc
  import math
  from typing import Dict, List, Optional, Tuple, Union
  import torch
  import torch.utils.checkpoint
  from torch import nn
  from ...activations import ACT2FN
  from ...modeling_outputs import BackboneOutput, BaseModelOutput
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from ...utils.backbone_utils import BackboneMixin
  from .configuration_vitdet import VitDetConfig
label_desc: Use image node_id 1 to create a new VitDetLayer object from inherited base classes: nn with example: obj = VitDetLayer(config, drop_path_rate, window_size, use_residual_block)