def affine_shift_matrix(wrg=(-<NUM_LIT:0.1>, <NUM_LIT:0.1>), hrg=(-<NUM_LIT:0.1>, <NUM_LIT:0.1>), w=<NUM_LIT:200>, h=<NUM_LIT:200>):
if isinstance(wrg, tuple):<EOL><INDENT>tx = np.random.uniform(wrg[<NUM_LIT:0>], wrg[<NUM_LIT:1>]) * w<EOL><DEDENT>else:<EOL><INDENT>tx = wrg * w<EOL><DEDENT>if isinstance(hrg, tuple):<EOL><INDENT>ty = np.random.uniform(hrg[<NUM_LIT:0>], hrg[<NUM_LIT:1>]) * h<EOL><DEDENT>else:<EOL><INDENT>ty = hrg * h<EOL><DEDENT>shift_matrix = np.array([[<NUM_LIT:1>, <NUM_LIT:0>, tx],[<NUM_LIT:0>, <NUM_LIT:1>, ty],[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>]])<EOL>return shift_matrix<EOL>
Create an affine transform matrix for image shifting.
    NOTE: In OpenCV, x is width and y is height.

    Parameters
    -----------
    wrg : float or tuple of floats
        Range to shift on width axis, -1 ~ 1.
            - float, a fixed distance.
            - tuple of 2 floats, randomly sample a value as the distance between these 2 values.
    hrg : float or tuple of floats
        Range to shift on height axis, -1 ~ 1.
            - float, a fixed distance.
            - tuple of 2 floats, randomly sample a value as the distance between these 2 values.
    w, h : int
        The width and height of the image.

    Returns
    -------
    numpy.array
        An affine transform matrix.