class_docstr: Global context head used in `SCNet <https://arxiv.org/abs/2012.10150>`_.
  
  Args:
      num_convs (int, optional): number of convolutional layer in GlbCtxHead.
          Defaults to 4.
      in_channels (int, optional): number of input channels. Defaults to 256.
      conv_out_channels (int, optional): number of output channels before
          classification layer. Defaults to 256.
      num_classes (int, optional): number of classes. Defaults to 80.
      loss_weight (float, optional): global context loss weight.
          Defaults to 1.
      conv_cfg (dict, optional): config to init conv layer. Defaults to None.
      norm_cfg (dict, optional): config to init norm layer. Defaults to None.
      conv_to_res (bool, optional): if True, 2 convs will be grouped into
          1 `SimplifiedBasicBlock` using a skip connection.
          Defaults to False.
      init_cfg (:obj:`ConfigDict` or dict or list[dict] or
          list[:obj:`ConfigDict`]): Initialization config dict. Defaults to
          dict(type='Normal', std=0.01, override=dict(name='fc')).
class_docstr_tok: ["Global","context","head","used","in","`","SCNet","<","https",":","\/\/arxiv.org\/abs\/2012.10150",">","`","_",".","Args",":","num_convs","(","int",",","optional",")",":","number","of","convolutional","layer","in","GlbCtxHead",".","Defaults","to","4.","in_channels","(","int",",","optional",")",":","number","of","input","channels",".","Defaults","to","256.","conv_out_channels","(","int",",","optional",")",":","number","of","output","channels","before","classification","layer",".","Defaults","to","256.","num_classes","(","int",",","optional",")",":","number","of","classes",".","Defaults","to","80.","loss_weight","(","float",",","optional",")",":","global","context","loss","weight",".","Defaults","to","1.","conv_cfg","(","dict",",","optional",")",":","config","to","init","conv","layer",".","Defaults","to","None",".","norm_cfg","(","dict",",","optional",")",":","config","to","init","norm","layer",".","Defaults","to","None",".","conv_to_res","(","bool",",","optional",")",":","if","True",",","2","convs","will","be","grouped","into","1","`","SimplifiedBasicBlock","`","using","a","skip","connection",".","Defaults","to","False",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict","or","list","[","dict","]","or","list","[",":","obj",":","`","ConfigDict","`","]",")",":","Initialization","config","dict",".","Defaults","to","dict","(","type='Normal","'",",","std=0.01",",","override=dict","(","name='fc","'",")",")","."]
docstr: Loss function.
  
  Args:
      pred (Tensor): Logits.
      labels (list[Tensor]): Grouth truths.
  
  Returns:
      Tensor: Loss.
docstr_tok: ["Loss","function",".","Args",":","pred","(","Tensor",")",":","Logits",".","labels","(","list","[","Tensor","]",")",":","Grouth","truths",".","Returns",":","Tensor",":","Loss","."]
code: def loss(self, pred: Tensor, labels: List[Tensor]) -> Tensor:
      """Loss function.
  
      Args:
          pred (Tensor): Logits.
          labels (list[Tensor]): Grouth truths.
  
      Returns:
          Tensor: Loss.
      """
      labels = [lbl.unique() for lbl in labels]
      targets = pred.new_zeros(pred.size())
      for i, label in enumerate(labels):
          targets[i, label] = 1.0
      loss = self.loss_weight * self.criterion(pred, targets)
      return loss
  
file_path: mmdetection/mmdet/models/roi_heads/mask_heads/global_context_head.py
imports: from typing import List, Tuple
  import torch.nn
  from mmcv.cnn import ConvModule
  from mmengine.model import BaseModule
  from torch import Tensor
  from mmdet.models.layers import ResLayer, SimplifiedBasicBlock
  from mmdet.registry import MODELS
  from mmdet.utils import MultiConfig, OptConfigType
label_desc: Use image node_id 3 for calling the GlobalContextHead obj's underlying member method code with example usage: obj.loss(pred, labels) and returns: loss