(
        img: Tensor,
        size: List[int])
return tl, tr, bl, br, center
Crop the given image into four corners and the central crop.
    If the image is torch Tensor, it is expected
    to have [..., H, W] shape, where ... means an arbitrary number of leading dimensions

    .. Note::
        This transform returns a tuple of images and there may be a
        mismatch in the number of inputs and targets your ``Dataset`` returns.

    Args:
        img (PIL Image or Tensor): Image to be cropped.
        size (sequence or int): Desired output size of the crop. If size is an
            int instead of sequence like (h, w), a square crop (size, size) is
            made. If provided a sequence of length 1, it will be interpreted as (size[0], size[0]).

    Returns:
       tuple: tuple (tl, tr, bl, br, center)
       Corresponding top left, top right, bottom left, bottom right and center crop.
Crop the given image into four corners and the central crop.
    If the image is torch Tensor, it is expected
    to have [..., H, W] shape, where ... means an arbitrary number of leading dimensions
Crop the given image into four corners and the central crop . If the image is torch Tensor it is expected to have [ ... H W ] shape where ... means an arbitrary number of leading dimensions
def five_crop(
        img: Tensor,
        size: List[int]) -> Tuple[Tensor, Tensor, Tensor, Tensor, Tensor]:
    """Crop the given image into four corners and the central crop.
    If the image is torch Tensor, it is expected
    to have [..., H, W] shape, where ... means an arbitrary number of leading dimensions

    .. Note::
        This transform returns a tuple of images and there may be a
        mismatch in the number of inputs and targets your ``Dataset`` returns.

    Args:
        img (PIL Image or Tensor): Image to be cropped.
        size (sequence or int): Desired output size of the crop. If size is an
            int instead of sequence like (h, w), a square crop (size, size) is
            made. If provided a sequence of length 1, it will be interpreted as (size[0], size[0]).

    Returns:
       tuple: tuple (tl, tr, bl, br, center)
       Corresponding top left, top right, bottom left, bottom right and center crop.
    """
    if isinstance(size, numbers.Number):
        size = (int(size), int(size))
    elif isinstance(size, (tuple, list)) and len(size) == 1:
        size = (size[0], size[0])

    if len(size) != 2:
        raise ValueError("Please provide only two dimensions (h, w) for size.")

    image_width, image_height = _get_image_size(img)
    crop_height, crop_width = size
    if crop_width > image_width or crop_height > image_height:
        msg = "Requested crop size {} is bigger than input size {}"
        raise ValueError(msg.format(size, (image_height, image_width)))

    tl = crop(img, 0, 0, crop_height, crop_width)
    tr = crop(img, 0, image_width - crop_width, crop_height, crop_width)
    bl = crop(img, image_height - crop_height, 0, crop_height, crop_width)
    br = crop(img, image_height - crop_height, image_width - crop_width,
              crop_height, crop_width)

    center = center_crop(img, [crop_height, crop_width])

    return tl, tr, bl, br, center
def five_crop ( img : Tensor , size : List [ int ] ) -> Tuple [ Tensor , Tensor , Tensor , Tensor , Tensor ] : if isinstance ( size , numbers . Number ) : size = ( int ( size ) , int ( size ) ) elif isinstance ( size , ( tuple , list ) ) and len ( size ) == 1 : size = ( size [ 0 ] , size [ 0 ] ) if len ( size ) != 2 : raise ValueError ( "Please provide only two dimensions (h, w) for size." ) image_width , image_height = _get_image_size ( img ) crop_height , crop_width = size if crop_width > image_width or crop_height > image_height : msg = "Requested crop size {} is bigger than input size {}" raise ValueError ( msg . format ( size , ( image_height , image_width ) ) ) tl = crop ( img , 0 , 0 , crop_height , crop_width ) tr = crop ( img , 0 , image_width - crop_width , crop_height , crop_width ) bl = crop ( img , image_height - crop_height , 0 , crop_height , crop_width ) br = crop ( img , image_height - crop_height , image_width - crop_width , crop_height , crop_width ) center = center_crop ( img , [ crop_height , crop_width ] ) return tl , tr , bl , br , center