(img: Tensor,
                   scale: Tuple[float, float],
                   ratio: Tuple[float, float],
                   value: Optional[List[float]]=None)
return 0, 0, img_h, img_w, img
Get parameters for ``erase`` for a random erasing.

        Args:
            img (Tensor): Tensor image to be erased.
            scale (sequence): range of proportion of erased area against input image.
            ratio (sequence): range of aspect ratio of erased area.
            value (list, optional): erasing value. If None, it is interpreted as "random"
                (erasing each pixel with random values). If ``len(value)`` is 1, it is interpreted as a number,
                i.e. ``value[0]``.

        Returns:
            tuple: params (i, j, h, w, v) to be passed to ``erase`` for random erasing.
Get parameters for ``erase`` for a random erasing.
Get parameters for erase for a random erasing .
def get_params(img: Tensor,
                   scale: Tuple[float, float],
                   ratio: Tuple[float, float],
                   value: Optional[List[float]]=None) -> Tuple[int, int, int,
                                                               int, Tensor]:
        """Get parameters for ``erase`` for a random erasing.

        Args:
            img (Tensor): Tensor image to be erased.
            scale (sequence): range of proportion of erased area against input image.
            ratio (sequence): range of aspect ratio of erased area.
            value (list, optional): erasing value. If None, it is interpreted as "random"
                (erasing each pixel with random values). If ``len(value)`` is 1, it is interpreted as a number,
                i.e. ``value[0]``.

        Returns:
            tuple: params (i, j, h, w, v) to be passed to ``erase`` for random erasing.
        """
        img_c, img_h, img_w = img.shape[-3], img.shape[-2], img.shape[-1]
        area = img_h * img_w

        log_ratio = torch.log(torch.tensor(ratio))
        for _ in range(10):
            erase_area = area * torch.empty(1).uniform_(scale[0],
                                                        scale[1]).item()
            aspect_ratio = torch.exp(
                torch.empty(1).uniform_(log_ratio[0], log_ratio[1])).item()

            h = int(round(math.sqrt(erase_area * aspect_ratio)))
            w = int(round(math.sqrt(erase_area / aspect_ratio)))
            if not (h < img_h and w < img_w):
                continue

            if value is None:
                v = torch.empty([img_c, h, w], dtype=torch.float32).normal_()
            else:
                v = torch.tensor(value)[:, None, None]

            i = torch.randint(0, img_h - h + 1, size=(1, )).item()
            j = torch.randint(0, img_w - w + 1, size=(1, )).item()
            return i, j, h, w, v

        # Return original image
        return 0, 0, img_h, img_w, img
def get_params ( img : Tensor , scale : Tuple [ float , float ] , ratio : Tuple [ float , float ] , value : Optional [ List [ float ] ] = None ) -> Tuple [ int , int , int , int , Tensor ] : img_c , img_h , img_w = img . shape [ - 3 ] , img . shape [ - 2 ] , img . shape [ - 1 ] area = img_h * img_w log_ratio = torch . log ( torch . tensor ( ratio ) ) for _ in range ( 10 ) : erase_area = area * torch . empty ( 1 ) . uniform_ ( scale [ 0 ] , scale [ 1 ] ) . item ( ) aspect_ratio = torch . exp ( torch . empty ( 1 ) . uniform_ ( log_ratio [ 0 ] , log_ratio [ 1 ] ) ) . item ( ) h = int ( round ( math . sqrt ( erase_area * aspect_ratio ) ) ) w = int ( round ( math . sqrt ( erase_area / aspect_ratio ) ) ) if not ( h < img_h and w < img_w ) : continue if value is None : v = torch . empty ( [ img_c , h , w ] , dtype = torch . float32 ) . normal_ ( ) else : v = torch . tensor ( value ) [ : , None , None ] i = torch . randint ( 0 , img_h - h + 1 , size = ( 1 , ) ) . item ( ) j = torch . randint ( 0 , img_w - w + 1 , size = ( 1 , ) ) . item ( ) return i , j , h , w , v # Return original image return 0 , 0 , img_h , img_w , img