code: def build_detection_loss(args, num_classes, attribute_head):
      matcher = HungarianMatcher(
          cost_class=args.set_cost_class,
          cost_bbox=args.set_cost_bbox,
          cost_giou=args.set_cost_giou,
          logsoftmax=args.use_bcl,
      )
      weight_dict = {"loss_ce": 1, "loss_bbox": args.bbox_loss_coef}
      weight_dict["loss_giou"] = args.giou_loss_coef
      weight_dict["loss_attr"] = args.attr_loss_coef
      if args.aux_loss:
          aux_weight_dict = {}
          for i in range(args.dec_layers - 1):
              aux_weight_dict.update(
                  {k + f"_{i}": v for k, v in weight_dict.items()}
              )
          weight_dict.update(aux_weight_dict)
  
      losses = []
      if args.use_bcl:
          losses.append("labels_balanced")
      else:
          losses.append("labels")
      losses.extend(["boxes", "cardinality"])
  
      criterion = SetCriterion(
          num_classes,
          matcher=matcher,
          weight_dict=weight_dict,
          eos_coef=args.eos_coef,
          losses=losses,
          attribute_head=attribute_head,
          attribute_class_num=args.attribute_class_num,
          max_attribute_num=args.max_attribute_num,
      )
      return criterion
  
imports: from typing import Optional
  import torch
  import torch.nn.functional
  from mmf.models.unit.backbone import build_unit_convnet_backbone
  from mmf.models.unit.matcher import HungarianMatcher
  from mmf.models.unit.misc import NestedTensor
  from mmf.models.unit.transformer import UniTTransformer
  from mmf.utils import box_ops
  from mmf.utils.distributed import get_world_size, is_dist_initialized
  from torch import nn, Tensor
label_desc: Use image node_id 1 for calling a global function with example usage: build_detection_loss(args, num_classes, attribute_head) and returns: criterion