code: def iou_loss(
      pred: Tensor,
      target: Tensor,
      linear: bool = False,
      mode: str = "log",
      eps: float = 1e-6,
  ) -> Tensor:
      """IoU loss.
  
      Computing the IoU loss between a set of predicted bboxes and target bboxes.
      The loss is calculated as negative log of IoU.
  
      Args:
          pred (Tensor): Predicted bboxes of format (x1, y1, x2, y2),
              shape (n, 4).
          target (Tensor): Corresponding gt bboxes, shape (n, 4).
          linear (bool, optional): If True, use linear scale of loss instead of
              log scale. Default: False.
          mode (str): Loss scaling mode, including "linear", "square", and "log".
              Default: 'log'
          eps (float): Epsilon to avoid log(0).
  
      Return:
          Tensor: Loss tensor.
      """
      assert mode in ["linear", "square", "log"]
      if linear:
          mode = "linear"
          warnings.warn(
              'DeprecationWarning: Setting "linear=True" in '
              'iou_loss is deprecated, please use "mode=`linear`" '
              "instead."
          )
      # avoid fp16 overflow
      if pred.dtype == torch.float16:
          fp16 = True
          pred = pred.to(torch.float32)
      else:
          fp16 = False
  
      ious = bbox_overlaps(pred, target, is_aligned=True).clamp(min=eps)
  
      if fp16:
          ious = ious.to(torch.float16)
  
      if mode == "linear":
          loss = 1 - ious
      elif mode == "square":
          loss = 1 - ious**2
      elif mode == "log":
          loss = -ious.log()
      else:
          raise NotImplementedError
      return loss
  
imports: import math
  import warnings
  from typing import Optional
  import torch
  import torch.nn
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures.bbox import bbox_overlaps
  from .utils import weighted_loss
label_desc: Use image node_id 1 for calling a global function with example usage: iou_loss(pred, target, linear, mode, eps) and returns: loss