class_docstr: ConvNeXt Block
  There are two equivalent implementations:
    (1) DwConv -> LayerNorm (channels_first) -> 1x1 Conv -> GELU -> 1x1 Conv; all in (N, C, H, W)
    (2) DwConv -> Permute to (N, H, W, C); LayerNorm (channels_last) -> Linear -> GELU -> Linear; Permute back
  
  Unlike the official impl, this one allows choice of 1 or 2, 1x1 conv can be faster with appropriate
  choice of LayerNorm impl, however as model size increases the tradeoffs appear to change and nn.Linear
  is a better choice. This was observed with PyTorch 1.10 on 3090 GPU, it could change over time & w/ different HW.
class_docstr_tok: ["ConvNeXt","Block","There","are","two","equivalent","implementations",":","(","1",")","DwConv","-",">","LayerNorm","(","channels_first",")","-",">","1x1","Conv","-",">","GELU","-",">","1x1","Conv",";","all","in","(","N",",","C",",","H",",","W",")","(","2",")","DwConv","-",">","Permute","to","(","N",",","H",",","W",",","C",")",";","LayerNorm","(","channels_last",")","-",">","Linear","-",">","GELU","-",">","Linear",";","Permute","back","Unlike","the","official","impl",",","this","one","allows","choice","of","1","or","2",",","1x1","conv","can","be","faster","with","appropriate","choice","of","LayerNorm","impl",",","however","as","model","size","increases","the","tradeoffs","appear","to","change","and","nn.Linear","is","a","better","choice",".","This","was","observed","with","PyTorch","1.10","on","3090","GPU",",","it","could","change","over","time","&","w\/","different","HW","."]
docstr: Args:
      in_chs: Block input channels.
      out_chs: Block output channels (same as in_chs if None).
      kernel_size: Depthwise convolution kernel size.
      stride: Stride of depthwise convolution.
      dilation: Tuple specifying input and output dilation of block.
      mlp_ratio: MLP expansion ratio.
      conv_mlp: Use 1x1 convolutions for MLP and a NCHW compatible norm layer if True.
      conv_bias: Apply bias for all convolution (linear) layers.
      use_grn: Use GlobalResponseNorm in MLP (from ConvNeXt-V2)
      ls_init_value: Layer-scale init values, layer-scale applied if not None.
      act_layer: Activation layer.
      norm_layer: Normalization layer (defaults to LN if not specified).
      drop_path: Stochastic depth probability.
code: def __init__(
      self,
      in_chs: int,
      out_chs: Optional[int] = None,
      kernel_size: int = 7,
      stride: int = 1,
      dilation: Union[int, Tuple[int, int]] = (1, 1),
      mlp_ratio: float = 4,
      conv_mlp: bool = False,
      conv_bias: bool = True,
      use_grn: bool = False,
      ls_init_value: Optional[float] = 1e-6,
      act_layer: Union[str, Callable] = "gelu",
      norm_layer: Optional[Callable] = None,
      drop_path: float = 0.0,
  ):
      """
  
      Args:
          in_chs: Block input channels.
          out_chs: Block output channels (same as in_chs if None).
          kernel_size: Depthwise convolution kernel size.
          stride: Stride of depthwise convolution.
          dilation: Tuple specifying input and output dilation of block.
          mlp_ratio: MLP expansion ratio.
          conv_mlp: Use 1x1 convolutions for MLP and a NCHW compatible norm layer if True.
          conv_bias: Apply bias for all convolution (linear) layers.
          use_grn: Use GlobalResponseNorm in MLP (from ConvNeXt-V2)
          ls_init_value: Layer-scale init values, layer-scale applied if not None.
          act_layer: Activation layer.
          norm_layer: Normalization layer (defaults to LN if not specified).
          drop_path: Stochastic depth probability.
      """
      super().__init__()
      out_chs = out_chs or in_chs
      dilation = to_ntuple(2)(dilation)
      act_layer = get_act_layer(act_layer)
      if not norm_layer:
          norm_layer = LayerNorm2d if conv_mlp else LayerNorm
      mlp_layer = partial(
          GlobalResponseNormMlp if use_grn else Mlp, use_conv=conv_mlp
      )
      self.use_conv_mlp = conv_mlp
      self.conv_dw = create_conv2d(
          in_chs,
          out_chs,
          kernel_size=kernel_size,
          stride=stride,
          dilation=dilation[0],
          depthwise=True,
          bias=conv_bias,
      )
      self.norm = norm_layer(out_chs)
      self.mlp = mlp_layer(
          out_chs, int(mlp_ratio * out_chs), act_layer=act_layer
      )
      self.gamma = (
          nn.Parameter(ls_init_value * torch.ones(out_chs))
          if ls_init_value is not None
          else None
      )
      if in_chs != out_chs or stride != 1 or dilation[0] != dilation[1]:
          self.shortcut = Downsample(
              in_chs, out_chs, stride=stride, dilation=dilation[0]
          )
      else:
          self.shortcut = nn.Identity()
      self.drop_path = (
          DropPath(drop_path) if drop_path > 0.0 else nn.Identity()
      )
  
imports: from collections import OrderedDict
  from functools import partial
  from typing import Callable, Optional, Tuple, Union
  import torch
  import torch.nn
  from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, OPENAI_CLIP_MEAN, OPENAI_CLIP_STD
  from timm.layers import trunc_normal_, AvgPool2dSame, DropPath, Mlp, GlobalResponseNormMlp, LayerNorm2d, LayerNorm, create_conv2d, get_act_layer, make_divisible, to_ntuple
  from timm.layers import NormMlpClassifierHead, ClassifierHead
  from ._builder import build_model_with_cfg
  from ._manipulate import named_apply, checkpoint_seq
  from ._registry import generate_default_cfgs, register_model, register_model_deprecations
label_desc: Use image node_id 1 to create a new ConvNeXtBlock object from inherited base classes: nn with example: obj = ConvNeXtBlock(in_chs, out_chs, kernel_size, stride, dilation, mlp_ratio, conv_mlp, conv_bias, use_grn, ls_init_value, act_layer, norm_layer, drop_path)