(img: Tensor,
                   output_size: Tuple[int, int])
return i, j, th, tw
Get parameters for ``crop`` for a random crop.

        Args:
            img (PIL Image or Tensor): Image to be cropped.
            output_size (tuple): Expected output size of the crop.

        Returns:
            tuple: params (i, j, h, w) to be passed to ``crop`` for random crop.
Get parameters for ``crop`` for a random crop.
Get parameters for crop for a random crop .
def get_params(img: Tensor,
                   output_size: Tuple[int, int]) -> Tuple[int, int, int, int]:
        """Get parameters for ``crop`` for a random crop.

        Args:
            img (PIL Image or Tensor): Image to be cropped.
            output_size (tuple): Expected output size of the crop.

        Returns:
            tuple: params (i, j, h, w) to be passed to ``crop`` for random crop.
        """
        w, h = F._get_image_size(img)
        th, tw = output_size

        if h + 1 < th or w + 1 < tw:
            raise ValueError(
                "Required crop size {} is larger then input image size {}".
                format((th, tw), (h, w)))

        if w == tw and h == th:
            return 0, 0, h, w

        i = torch.randint(0, h - th + 1, size=(1, )).item()
        j = torch.randint(0, w - tw + 1, size=(1, )).item()
        return i, j, th, tw
def get_params ( img : Tensor , output_size : Tuple [ int , int ] ) -> Tuple [ int , int , int , int ] : w , h = F . _get_image_size ( img ) th , tw = output_size if h + 1 < th or w + 1 < tw : raise ValueError ( "Required crop size {} is larger then input image size {}" . format ( ( th , tw ) , ( h , w ) ) ) if w == tw and h == th : return 0 , 0 , h , w i = torch . randint ( 0 , h - th + 1 , size = ( 1 , ) ) . item ( ) j = torch . randint ( 0 , w - tw + 1 , size = ( 1 , ) ) . item ( ) return i , j , th , tw