class_docstr: Implementation of the MaxViT proposed in:
  https://arxiv.org/pdf/2204.01697.pdf
  
  Args:
      in_channels (`int`):
          Number of input channels to the convolutional stem. Default 3
      depths (`Tuple[int, ...]`):
          Depth of each network stage. Default (2, 2, 5, 2)
      channels (`Tuple[int, ...]`):
          Number of channels in each network stage. Default (64, 128, 256, 512)
      num_classes (`int`):
          Number of classes to be predicted. Default 1000
      embed_dim (`int`):
          Embedding dimension of the convolutional stem. Default 64
      num_heads (`int`):
          Number of attention heads. Default 32
      grid_window_size (`Tuple[int, int]`):
          Grid/Window size to be utilized. Default (7, 7)
      attn_drop (`float`):
          Dropout ratio of attention weight. Default: 0.0
      drop (`float`):
          Dropout ratio of output. Default: 0.0
      drop_path (`float`):
          Dropout ratio of path. Default: 0.0
      mlp_ratio (`float`):
          Ratio of mlp hidden dim to embedding dim. Default: 4.0
      act_layer (`nn.Module`):
          Type of activation layer to be utilized. Default: nn.GELU
      norm_layer (`nn.Module`):
          Type of normalization layer to be utilized. Default: nn.BatchNorm2d
      norm_layer_transformer (`nn.Module`):
          Normalization layer in Transformer. Default: nn.LayerNorm
      global_pool (`str`):
          Global polling type to be utilized. Default "avg"
class_docstr_tok: ["Implementation","of","the","MaxViT","proposed","in",":","https",":","\/\/arxiv.org\/pdf\/2204.01697.pdf","Args",":","in_channels","(","`","int","`",")",":","Number","of","input","channels","to","the","convolutional","stem",".","Default","3","depths","(","`","Tuple","[","int",",","...","]","`",")",":","Depth","of","each","network","stage",".","Default","(","2",",","2",",","5",",","2",")","channels","(","`","Tuple","[","int",",","...","]","`",")",":","Number","of","channels","in","each","network","stage",".","Default","(","64",",","128",",","256",",","512",")","num_classes","(","`","int","`",")",":","Number","of","classes","to","be","predicted",".","Default","1000","embed_dim","(","`","int","`",")",":","Embedding","dimension","of","the","convolutional","stem",".","Default","64","num_heads","(","`","int","`",")",":","Number","of","attention","heads",".","Default","32","grid_window_size","(","`","Tuple","[","int",",","int","]","`",")",":","Grid\/Window","size","to","be","utilized",".","Default","(","7",",","7",")","attn_drop","(","`","float","`",")",":","Dropout","ratio","of","attention","weight",".","Default",":","0.0","drop","(","`","float","`",")",":","Dropout","ratio","of","output",".","Default",":","0.0","drop_path","(","`","float","`",")",":","Dropout","ratio","of","path",".","Default",":","0.0","mlp_ratio","(","`","float","`",")",":","Ratio","of","mlp","hidden","dim","to","embedding","dim",".","Default",":","4.0","act_layer","(","`","nn.Module","`",")",":","Type","of","activation","layer","to","be","utilized",".","Default",":","nn.GELU","norm_layer","(","`","nn.Module","`",")",":","Type","of","normalization","layer","to","be","utilized",".","Default",":","nn.BatchNorm2d","norm_layer_transformer","(","`","nn.Module","`",")",":","Normalization","layer","in","Transformer",".","Default",":","nn.LayerNorm","global_pool","(","`","str","`",")",":","Global","polling","type","to","be","utilized",".","Default","``","avg","''"]
docstr: Constructor method 
docstr_tok: ["Constructor","method"]
code: def __init__(
      self,
      in_channels: int = 3,
      depths: Tuple[int, ...] = (2, 2, 5, 2),
      channels: Tuple[int, ...] = (64, 128, 256, 512),
      num_classes: int = 1000,
      embed_dim: int = 64,
      num_heads: int = 32,
      grid_window_size: Tuple[int, int] = (7, 7),
      attn_drop: float = 0.0,
      drop: float = 0.0,
      drop_path: float = 0.0,
      mlp_ratio: float = 4.0,
      act_layer=nn.GELU,
      norm_layer=nn.BatchNorm2d,
      norm_layer_transformer=nn.LayerNorm,
      global_pool: str = "avg",
  ) -> None:
      """Constructor method"""
      # Call super constructor
      super().__init__()
      # Check parameters
      assert len(depths) == len(
          channels
      ), "For each stage a channel dimension must be given."
      assert global_pool in [
          "avg",
          "max",
      ], f"Only avg and max is supported but {global_pool} is given"
      # Save parameters
      self.num_classes: int = num_classes
      # Init convolutional stem
      self.stem = nn.Sequential(
          nn.Conv2d(
              in_channels=in_channels,
              out_channels=embed_dim,
              kernel_size=(3, 3),
              stride=(2, 2),
              padding=(1, 1),
          ),
          act_layer(),
          nn.Conv2d(
              in_channels=embed_dim,
              out_channels=embed_dim,
              kernel_size=(3, 3),
              stride=(1, 1),
              padding=(1, 1),
          ),
          act_layer(),
      )
      # Init blocks
      drop_path = torch.linspace(0.0, drop_path, sum(depths)).tolist()
      stages = []
      for index, (depth, channel) in enumerate(zip(depths, channels)):
          stages.append(
              MaxViTStage(
                  depth=depth,
                  in_channels=embed_dim
                  if index == 0
                  else channels[index - 1],
                  out_channels=channel,
                  num_heads=num_heads,
                  grid_window_size=grid_window_size,
                  attn_drop=attn_drop,
                  drop=drop,
                  drop_path=drop_path[
                      sum(depths[:index]) : sum(depths[: index + 1])
                  ],
                  mlp_ratio=mlp_ratio,
                  act_layer=act_layer,
                  norm_layer=norm_layer,
                  norm_layer_transformer=norm_layer_transformer,
              )
          )
      self.stages = nn.Sequential(*stages)
      self.global_pool: str = global_pool
      self.head = nn.Linear(channels[-1], num_classes)
  
file_path: towhee/towhee/models/max_vit/max_vit.py
imports: from typing import Tuple, Optional
  import torch
  from torch import nn
  from towhee.models.max_vit.max_vit_block import MaxViTStage
  from towhee.models.max_vit.configs import get_configs
  from towhee.models.utils import create_model
label_desc: Use image node_id 1 to create a new MaxViT object from inherited base classes: nn with example: obj = MaxViT(in_channels, depths, channels, num_classes, embed_dim, num_heads, grid_window_size, attn_drop, drop, drop_path, mlp_ratio, act_layer, norm_layer, norm_layer_transformer, global_pool)