class_docstr: The horizontal box class used in MMDetection by default.
  
  The ``box_dim`` of ``HorizontalBoxes`` is 4, which means the length of
  the last dimension of the data should be 4. Two modes of box data are
  supported in ``HorizontalBoxes``:
  
  - 'xyxy': Each row of data indicates (x1, y1, x2, y2), which are the
    coordinates of the left-top and right-bottom points.
  - 'cxcywh': Each row of data indicates (x, y, w, h), where (x, y) are the
    coordinates of the box centers and (w, h) are the width and height.
  
  ``HorizontalBoxes`` only restores 'xyxy' mode of data. If the the data is
  in 'cxcywh' mode, users need to input ``in_mode='cxcywh'`` and The code
  will convert the 'cxcywh' data to 'xyxy' automatically.
  
  Args:
      data (Tensor or np.ndarray or Sequence): The box data with shape of
          (..., 4).
      dtype (torch.dtype, Optional): data type of boxes. Defaults to None.
      device (str or torch.device, Optional): device of boxes.
          Default to None.
      clone (bool): Whether clone ``boxes`` or not. Defaults to True.
      mode (str, Optional): the mode of boxes. If it is 'cxcywh', the
          `data` will be converted to 'xyxy' mode. Defaults to None.
class_docstr_tok: ["The","horizontal","box","class","used","in","MMDetection","by","default",".","The","``","box_dim","``","of","``","HorizontalBoxes","``","is","4",",","which","means","the","length","of","the","last","dimension","of","the","data","should","be","4",".","Two","modes","of","box","data","are","supported","in","``","HorizontalBoxes","``",":","-","'xyxy","'",":","Each","row","of","data","indicates","(","x1",",","y1",",","x2",",","y2",")",",","which","are","the","coordinates","of","the","left-top","and","right-bottom","points",".","-","'cxcywh","'",":","Each","row","of","data","indicates","(","x",",","y",",","w",",","h",")",",","where","(","x",",","y",")","are","the","coordinates","of","the","box","centers","and","(","w",",","h",")","are","the","width","and","height",".","``","HorizontalBoxes","``","only","restores","'xyxy","'","mode","of","data",".","If","the","the","data","is","in","'cxcywh","'","mode",",","users","need","to","input","``","in_mode='cxcywh","'","``","and","The","code","will","convert","the","'cxcywh","'","data","to","'xyxy","'","automatically",".","Args",":","data","(","Tensor","or","np.ndarray","or","Sequence",")",":","The","box","data","with","shape","of","(","...",",","4",")",".","dtype","(","torch.dtype",",","Optional",")",":","data","type","of","boxes",".","Defaults","to","None",".","device","(","str","or","torch.device",",","Optional",")",":","device","of","boxes",".","Default","to","None",".","clone","(","bool",")",":","Whether","clone","``","boxes","``","or","not",".","Defaults","to","True",".","mode","(","str",",","Optional",")",":","the","mode","of","boxes",".","If","it","is","'cxcywh","'",",","the","`","data","`","will","be","converted","to","'xyxy","'","mode",".","Defaults","to","None","."]
docstr: Convert box coordinates from corners ((x1, y1), (x2, y1), (x1, y2),
  (x2, y2)) to (x1, y1, x2, y2).
  
  Args:
      corners (Tensor): Corner tensor with shape of (..., 4, 2).
  
  Returns:
      Tensor: Horizontal box tensor with shape of (..., 4).
docstr_tok: ["Convert","box","coordinates","from","corners","(","(","x1",",","y1",")",",","(","x2",",","y1",")",",","(","x1",",","y2",")",",","(","x2",",","y2",")",")","to","(","x1",",","y1",",","x2",",","y2",")",".","Args",":","corners","(","Tensor",")",":","Corner","tensor","with","shape","of","(","...",",","4",",","2",")",".","Returns",":","Tensor",":","Horizontal","box","tensor","with","shape","of","(","...",",","4",")","."]
code: def corner2hbox(corners: Tensor) -> Tensor:
      """Convert box coordinates from corners ((x1, y1), (x2, y1), (x1, y2),
      (x2, y2)) to (x1, y1, x2, y2).
  
      Args:
          corners (Tensor): Corner tensor with shape of (..., 4, 2).
  
      Returns:
          Tensor: Horizontal box tensor with shape of (..., 4).
      """
      if corners.numel() == 0:
          return corners.new_zeros((0, 4))
      min_xy = corners.min(dim=-2)[0]
      max_xy = corners.max(dim=-2)[0]
      return torch.cat([min_xy, max_xy], dim=-1)
  
imports: from typing import Optional, Tuple, TypeVar, Union
  import cv2
  import numpy
  import torch
  from torch import BoolTensor, Tensor
  from mmdet.structures.mask.structures import BitmapMasks, PolygonMasks
  from .base_boxes import BaseBoxes
  from .bbox_overlaps import bbox_overlaps
  from .box_type import register_box
label_desc: Use image node_id 15 for calling the HorizontalBoxes obj's underlying member method code with example usage: obj.corner2hbox(corners) and returns: torch, corners