class_docstr: BasicHead. No pool.
class_docstr_tok: ["BasicHead",".","No","pool","."]
docstr: Perform linear projection and activation as head for tranformers.
  Args:
      dim_in (int): the channel dimension of the input to the head.
      num_classes (int): the channel dimensions of the output to the head.
      dropout_rate (float): dropout rate. If equal to 0.0, perform no
          dropout.
      act_func (string): activation function to use. 'softmax': applies
          softmax on the output. 'sigmoid': applies sigmoid on the output.
docstr_tok: ["Perform","linear","projection","and","activation","as","head","for","tranformers",".","Args",":","dim_in","(","int",")",":","the","channel","dimension","of","the","input","to","the","head",".","num_classes","(","int",")",":","the","channel","dimensions","of","the","output","to","the","head",".","dropout_rate","(","float",")",":","dropout","rate",".","If","equal","to","0.0",",","perform","no","dropout",".","act_func","(","string",")",":","activation","function","to","use",".","'softmax","'",":","applies","softmax","on","the","output",".","'sigmoid","'",":","applies","sigmoid","on","the","output","."]
code: def __init__(
      self,
      dim_in,
      num_classes,
      dropout_rate=0.0,
      act_func="softmax",
      cfg=None,
  ):
      """
      Perform linear projection and activation as head for tranformers.
      Args:
          dim_in (int): the channel dimension of the input to the head.
          num_classes (int): the channel dimensions of the output to the head.
          dropout_rate (float): dropout rate. If equal to 0.0, perform no
              dropout.
          act_func (string): activation function to use. 'softmax': applies
              softmax on the output. 'sigmoid': applies sigmoid on the output.
      """
      super(TransformerBasicHead, self).__init__()
      if dropout_rate > 0.0:
          self.dropout = nn.Dropout(dropout_rate)
      self.projection = nn.Linear(dim_in, num_classes, bias=True)
  
      if cfg.CONTRASTIVE.NUM_MLP_LAYERS == 1:
          self.projection = nn.Linear(dim_in, num_classes, bias=True)
      else:
          self.projection = MLPHead(
              dim_in,
              num_classes,
              cfg.CONTRASTIVE.MLP_DIM,
              cfg.CONTRASTIVE.NUM_MLP_LAYERS,
              bn_on=cfg.CONTRASTIVE.BN_MLP,
              bn_sync_num=cfg.BN.NUM_SYNC_DEVICES
              if cfg.CONTRASTIVE.BN_SYNC_MLP
              else 1,
              global_sync=(
                  cfg.CONTRASTIVE.BN_SYNC_MLP and cfg.BN.GLOBAL_SYNC
              ),
          )
      self.detach_final_fc = cfg.MODEL.DETACH_FINAL_FC
  
      # Softmax for evaluation and testing.
      if act_func == "softmax":
          self.act = nn.Softmax(dim=1)
      elif act_func == "sigmoid":
          self.act = nn.Sigmoid()
      elif act_func == "none":
          self.act = None
      else:
          raise NotImplementedError(
              "{} is not supported as an activation"
              "function.".format(act_func)
          )
  
imports: from functools import partial
  import torch
  import torch.nn
  from detectron2.layers import ROIAlign
  import slowfast.utils.logging
  from slowfast.models.attention import MultiScaleBlock
  from slowfast.models.batchnorm_helper import NaiveSyncBatchNorm1d
  from slowfast.models.nonlocal_helper import Nonlocal
label_desc: Use image node_id 1 to create a new TransformerBasicHead object from inherited base classes: nn with example: obj = TransformerBasicHead(dim_in, num_classes, dropout_rate, act_func, cfg)