class_docstr: BoxInst mask head used in https://arxiv.org/abs/2012.02310.
  
  This head outputs the mask for BoxInst.
  
  Args:
      pairwise_size (dict): The size of neighborhood for each pixel.
          Defaults to 3.
      pairwise_dilation (int): The dilation of neighborhood for each pixel.
          Defaults to 2.
      warmup_iters (int): Warmup iterations for pair-wise loss.
          Defaults to 10000.
class_docstr_tok: ["BoxInst","mask","head","used","in","https",":","\/\/arxiv.org\/abs\/2012.02310",".","This","head","outputs","the","mask","for","BoxInst",".","Args",":","pairwise_size","(","dict",")",":","The","size","of","neighborhood","for","each","pixel",".","Defaults","to","3.","pairwise_dilation","(","int",")",":","The","dilation","of","neighborhood","for","each","pixel",".","Defaults","to","2.","warmup_iters","(","int",")",":","Warmup","iterations","for","pair-wise","loss",".","Defaults","to","10000","."]
docstr: Compute the pairwise affinity for each pixel.
docstr_tok: ["Compute","the","pairwise","affinity","for","each","pixel","."]
code: def get_pairwise_affinity(self, mask_logits: Tensor) -> Tensor:
      """Compute the pairwise affinity for each pixel."""
      log_fg_prob = F.logsigmoid(mask_logits).unsqueeze(1)
      log_bg_prob = F.logsigmoid(-mask_logits).unsqueeze(1)
  
      log_fg_prob_unfold = unfold_wo_center(
          log_fg_prob,
          kernel_size=self.pairwise_size,
          dilation=self.pairwise_dilation,
      )
      log_bg_prob_unfold = unfold_wo_center(
          log_bg_prob,
          kernel_size=self.pairwise_size,
          dilation=self.pairwise_dilation,
      )
  
      # the probability of making the same prediction:
      # p_i * p_j + (1 - p_i) * (1 - p_j)
      # we compute the the probability in log space
      # to avoid numerical instability
      log_same_fg_prob = log_fg_prob[:, :, None] + log_fg_prob_unfold
      log_same_bg_prob = log_bg_prob[:, :, None] + log_bg_prob_unfold
  
      # TODO: Figure out the difference between it and directly sum
      max_ = torch.max(log_same_fg_prob, log_same_bg_prob)
      log_same_prob = (
          torch.log(
              torch.exp(log_same_fg_prob - max_)
              + torch.exp(log_same_bg_prob - max_)
          )
          + max_
      )
  
      return -log_same_prob[:, 0]
  
file_path: mmdetection/mmdet/models/dense_heads/boxinst_head.py
imports: from typing import List
  import torch
  import torch.nn.functional
  from mmengine import MessageHub
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.utils import InstanceList
  from ..utils.misc import unfold_wo_center
  from .condinst_head import CondInstBboxHead, CondInstMaskHead
label_desc: Use image node_id 2 for calling the BoxInstMaskHead obj's underlying member method code with example usage: obj.get_pairwise_affinity(mask_logits) and returns: unknown