class_docstr: ACAR head of ACAR-Net
  Args:
      width (`int`):
          Input dimension of linear layer.
      roi_spatial (`int`):
          Portion to filter in spatial dimension.
      num_classes (`int`):
          Number of classes.
     dropout (`float`):
          Dropout ratio.
      bias (`bool`):
          Flag to control if use bias.
      reduce_dim (`int`):
          Reduce dimension.
      hidden_dim (`int`):
          Hidden dimension.
      downsample (`str`):
          downsample layer.
      depth (`int`):
          depth.
      kernel_size (`int`):
          kernel size
      mlp_1x1 (`bool`):
          use mlp_1x1
class_docstr_tok: ["ACAR","head","of","ACAR-Net","Args",":","width","(","`","int","`",")",":","Input","dimension","of","linear","layer",".","roi_spatial","(","`","int","`",")",":","Portion","to","filter","in","spatial","dimension",".","num_classes","(","`","int","`",")",":","Number","of","classes",".","dropout","(","`","float","`",")",":","Dropout","ratio",".","bias","(","`","bool","`",")",":","Flag","to","control","if","use","bias",".","reduce_dim","(","`","int","`",")",":","Reduce","dimension",".","hidden_dim","(","`","int","`",")",":","Hidden","dimension",".","downsample","(","`","str","`",")",":","downsample","layer",".","depth","(","`","int","`",")",":","depth",".","kernel_size","(","`","int","`",")",":","kernel","size","mlp_1x1","(","`","bool","`",")",":","use","mlp_1x1"]
code: def __init__(
      self,
      width,
      roi_spatial=7,
      num_classes=60,
      dropout=0.0,
      bias=False,
      reduce_dim=1024,
      hidden_dim=512,
      downsample="max2x2",
      depth=2,
      kernel_size=3,
      mlp_1x1=False,
  ):
      super().__init__()
  
      self.roi_spatial = roi_spatial
      self.roi_maxpool = nn.MaxPool2d(roi_spatial)
  
      # actor-context feature encoder
      self.conv_reduce = nn.Conv2d(width, reduce_dim, 1, bias=False)
  
      self.conv1 = nn.Conv2d(reduce_dim * 2, hidden_dim, 1, bias=False)
      self.conv2 = nn.Conv2d(hidden_dim, hidden_dim, 3, bias=False)
  
      # down-sampling before HR2O
      assert downsample in ["none", "max2x2"]
      if downsample == "none":
          self.downsample = nn.Identity()
      elif downsample == "max2x2":
          self.downsample = nn.MaxPool2d(
              kernel_size=3, stride=2, padding=1
          )
  
      # high-order relation reasoning operator (HR2ONL)
      layers = []
      for _ in range(depth):
          layers.append(HR2ONL(hidden_dim, kernel_size, mlp_1x1))
      self.hr2o = nn.Sequential(*layers)
  
      # classification
      self.gap = nn.AdaptiveAvgPool2d(1)
      self.fc1 = nn.Linear(reduce_dim, hidden_dim, bias=False)
      self.fc2 = nn.Linear(hidden_dim * 2, num_classes, bias=bias)
  
      if dropout > 0:
          self.dp = nn.Dropout(dropout)
      else:
          self.dp = None
  
file_path: towhee/towhee/models/acar_net/head.py
imports: import math
  import torch
  from torch import nn
  import torchvision
label_desc: Use image node_id 1 to create a new ACARHead object from inherited base classes: nn with example: obj = ACARHead(width, roi_spatial, num_classes, dropout, bias, reduce_dim, hidden_dim, downsample, depth, kernel_size, mlp_1x1)