(degrees: List[float],
                   translate: Optional[List[float]],
                   scale_ranges: Optional[List[float]],
                   shears: Optional[List[float]],
                   img_size: List[int])
return angle, translations, scale, shear
Get parameters for affine transformation

        Returns:
            params to be passed to the affine transformation
Get parameters for affine transformation
Get parameters for affine transformation
def get_params(degrees: List[float],
                   translate: Optional[List[float]],
                   scale_ranges: Optional[List[float]],
                   shears: Optional[List[float]],
                   img_size: List[int]) -> Tuple[float, Tuple[int, int], float,
                                                 Tuple[float, float]]:
        """Get parameters for affine transformation

        Returns:
            params to be passed to the affine transformation
        """
        angle = float(
            torch.empty(1).uniform_(float(degrees[0]), float(degrees[1])).item(
            ))
        if translate is not None:
            max_dx = float(translate[0] * img_size[0])
            max_dy = float(translate[1] * img_size[1])
            tx = int(round(torch.empty(1).uniform_(-max_dx, max_dx).item()))
            ty = int(round(torch.empty(1).uniform_(-max_dy, max_dy).item()))
            translations = (tx, ty)
        else:
            translations = (0, 0)

        if scale_ranges is not None:
            scale = float(
                torch.empty(1).uniform_(scale_ranges[0], scale_ranges[1]).item(
                ))
        else:
            scale = 1.0

        shear_x = shear_y = 0.0
        if shears is not None:
            shear_x = float(
                torch.empty(1).uniform_(shears[0], shears[1]).item())
            if len(shears) == 4:
                shear_y = float(
                    torch.empty(1).uniform_(shears[2], shears[3]).item())

        shear = (shear_x, shear_y)

        return angle, translations, scale, shear
def get_params ( degrees : List [ float ] , translate : Optional [ List [ float ] ] , scale_ranges : Optional [ List [ float ] ] , shears : Optional [ List [ float ] ] , img_size : List [ int ] ) -> Tuple [ float , Tuple [ int , int ] , float , Tuple [ float , float ] ] : angle = float ( torch . empty ( 1 ) . uniform_ ( float ( degrees [ 0 ] ) , float ( degrees [ 1 ] ) ) . item ( ) ) if translate is not None : max_dx = float ( translate [ 0 ] * img_size [ 0 ] ) max_dy = float ( translate [ 1 ] * img_size [ 1 ] ) tx = int ( round ( torch . empty ( 1 ) . uniform_ ( - max_dx , max_dx ) . item ( ) ) ) ty = int ( round ( torch . empty ( 1 ) . uniform_ ( - max_dy , max_dy ) . item ( ) ) ) translations = ( tx , ty ) else : translations = ( 0 , 0 ) if scale_ranges is not None : scale = float ( torch . empty ( 1 ) . uniform_ ( scale_ranges [ 0 ] , scale_ranges [ 1 ] ) . item ( ) ) else : scale = 1.0 shear_x = shear_y = 0.0 if shears is not None : shear_x = float ( torch . empty ( 1 ) . uniform_ ( shears [ 0 ] , shears [ 1 ] ) . item ( ) ) if len ( shears ) == 4 : shear_y = float ( torch . empty ( 1 ) . uniform_ ( shears [ 2 ] , shears [ 3 ] ) . item ( ) ) shear = ( shear_x , shear_y ) return angle , translations , scale , shear