code: def __init__(
      self,
      in_channels: int,
      pixel_decoder: nn.Module,
      transformer_decoder: nn.Module,
      task: str = "semseg",
      test_cfg=None,
  ):
      super().__init__()
      self.task = task
      self.test_cfg = test_cfg
  
      pixel_decoder_ = copy.deepcopy(pixel_decoder)
      pixel_decoder_.update(in_channels=in_channels)
      self.pixel_decoder = MODELS.build(pixel_decoder_)
  
      transformer_decoder_ = copy.deepcopy(transformer_decoder)
      transformer_decoder_.update(task=task)
      self.predictor = MODELS.build(transformer_decoder_)
  
      self.return_inter_mask = False
      if self.task == "ref-caption":
          # ref-caption = ref-seg + caption,
          # so we need to return the intermediate mask
          self.return_inter_mask = True
  
      self._all_text_prompts = None
      self._extra = None
      # TODO: Very trick, for retrieval task
      self._force_not_use_cache = False
  
file_path: mmdetection/projects/XDecoder/xdecoder/unified_head.py
imports: import copy
  from typing import Sequence
  import torch
  from mmengine.structures import InstanceData, PixelData
  from torch import nn
  from torch.nn import functional
  from mmdet.evaluation.functional import INSTANCE_OFFSET
  from mmdet.registry import MODELS
  from .utils import is_lower_torch_version, retry_if_cuda_oom, sem_seg_postprocess
label_desc: Use image node_id 1 to create a new XDecoderUnifiedhead object from inherited base classes: nn with example: obj = XDecoderUnifiedhead(in_channels, pixel_decoder, transformer_decoder, task, test_cfg)