class_docstr: Linear 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.
class_docstr_tok: ["Linear","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","."]
code: def forward(self, data):
      if not isinstance(data["features"], list):
          features = [data["features"]]
      else:
          features = data["features"]
  
      roi_features = []
      for f in features:
          sp = f.shape
          h, w = sp[3:]
          feats = nn.AdaptiveAvgPool3d((1, h, w))(f).view(
              -1, sp[1], h, w
          )
  
          rois = data["rois"].clone()
          rois[:, 1] = rois[:, 1] * w
          rois[:, 2] = rois[:, 2] * h
          rois[:, 3] = rois[:, 3] * w
          rois[:, 4] = rois[:, 4] * h
          rois = rois.detach()
          roi_feats = torchvision.ops.roi_align(
              feats, rois, (self.roi_spatial, self.roi_spatial)
          )
          roi_feats = self.roi_maxpool(roi_feats).view(-1, sp[1])
  
          roi_features.append(roi_feats)
  
      roi_features = torch.cat(roi_features, dim=1)
      if self.dp is not None:
          roi_features = self.dp(roi_features)
      outputs = self.fc(roi_features)
  
      return outputs
  
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 2 for calling the LinearHead obj's underlying member method code with example usage: obj.forward(data) and returns: outputs