code: def classifier_loss_calculation(
      self, detr_outputs: Dict[str, Tensor], sample_list
  ):
      task_type = self.get_task_type(sample_list.dataset_name)
      hs = detr_outputs["hidden_states"]
      if not self.config.loss_on_all_hs:
          hs = detr_outputs["hidden_states"][-1:]
      num_queries = self.config.base_args.num_queries[task_type][
          sample_list.dataset_name
      ]
      assert hs[0].size(1) == num_queries
      losses = {}
      scores = None
      detr_outputs = {}
      num_labels = self.config.heads[task_type][
          sample_list.dataset_name
      ]["num_labels"]
  
      for idx, current_hs in enumerate(hs):
          pooled_output = current_hs[:, -num_queries, :]
          pooled_output = self.dropout(pooled_output)
          logits = self.classifiers[task_type][
              sample_list.dataset_name
          ](pooled_output)
          reshaped_logits = logits.contiguous().view(-1, num_labels)
          scores = reshaped_logits
          # skip loss computation on test set (which usually doesn't contain labels)
          if sample_list.dataset_type != "test":
              loss_prefix = f"{sample_list.dataset_type}/{sample_list.dataset_name}/"
              loss = self.losses_dict[task_type][
                  sample_list.dataset_name
              ](scores, sample_list.targets)
              if sample_list.dataset_name == "vqa2":
                  loss *= sample_list.targets.size(1)
              losses[loss_prefix + f"loss_{idx}"] = loss
  
      detr_outputs["scores"] = scores
      detr_outputs["losses"] = losses
      return detr_outputs
  
imports: import logging
  from copy import deepcopy
  from typing import Dict
  import torch
  from mmf.common.registry import registry
  from mmf.models import BaseModel
  from mmf.models.unit.unit_base_model import AttributeHead, build_detection_loss, MLP, UniTBaseModel
  from mmf.modules.encoders import TransformerEncoder
  from mmf.utils.distributed import byte_tensor_to_object
  from torch import nn, Tensor
label_desc: Use image node_id 8 for calling the UniT obj's underlying member method code with example usage: obj.classifier_loss_calculation(detr_outputs, sample_list) and returns: detr_outputs