code: def translate_labels_x1y1x2y2_to_xcycwh(
      labels_x1y1x2y2: List[Dict[str, "torch.Tensor"]],
      height: int,
      width: int,
  ) -> "torch.Tensor":
      """
      Translate object detection labels from x1y1x2y2 (torchvision) to xcycwh (YOLO).
  
      :param labels_x1y1x2y2: Object detection labels in format x1y1x2y2 (torchvision).
      :param height: Height of images in pixels.
      :param width: Width if images in pixels.
      :return: Object detection labels in format xcycwh (YOLO).
      """
      import torch
  
      labels_xcycwh_list = []
      device = labels_x1y1x2y2[0]["boxes"].device
  
      for i, label_dict in enumerate(labels_x1y1x2y2):
          # create 2D tensor to encode labels and bounding boxes
          labels = torch.zeros(
              len(label_dict["boxes"]), 6, device=device
          )
          labels[:, 0] = i
          labels[:, 1] = label_dict["labels"]
          labels[:, 2:6] = label_dict["boxes"]
  
          # normalize bounding boxes to [0, 1]
          labels[:, 2:6:2] = labels[:, 2:6:2] / width
          labels[:, 3:6:2] = labels[:, 3:6:2] / height
  
          # convert from x1y1x2y2 to xcycwh
          labels[:, 4] -= labels[:, 2]
          labels[:, 5] -= labels[:, 3]
          labels[:, 2] += labels[:, 4] / 2
          labels[:, 3] += labels[:, 5] / 2
          labels_xcycwh_list.append(labels)
  
      labels_xcycwh = torch.vstack(labels_xcycwh_list)
  
      return labels_xcycwh
  
imports: import logging
  from typing import List, Dict, Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  from art.estimators.object_detection.object_detector import ObjectDetectorMixin
  from art.estimators.object_detection.utils import cast_inputs_to_pt
  from art.estimators.pytorch import PyTorchEstimator
label_desc: Use image node_id 2 for calling a global function with example usage: translate_labels_x1y1x2y2_to_xcycwh(labels_x1y1x2y2, height, width) and returns: labels_xcycwh