def shift(<EOL>x, wrg=<NUM_LIT:0.1>, hrg=<NUM_LIT:0.1>, is_random=False, row_index=<NUM_LIT:0>, col_index=<NUM_LIT:1>, channel_index=<NUM_LIT:2>, fill_mode='<STR_LIT>', cval=<NUM_LIT:0.>,<EOL>order=<NUM_LIT:1><EOL>):
h, w = x.shape[row_index], x.shape[col_index]<EOL>if is_random:<EOL><INDENT>tx = np.random.uniform(-hrg, hrg) * h<EOL>ty = np.random.uniform(-wrg, wrg) * w<EOL><DEDENT>else:<EOL><INDENT>tx, ty = hrg * h, wrg * w<EOL><DEDENT>translation_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>transform_matrix = translation_matrix  <EOL>x = affine_transform(x, transform_matrix, channel_index, fill_mode, cval, order)<EOL>return x<EOL>
Shift an image randomly or non-randomly.

    Parameters
    -----------
    x : numpy.array
        An image with dimension of [row, col, channel] (default).
    wrg : float
        Percentage of shift in axis x, usually -0.25 ~ 0.25.
    hrg : float
        Percentage of shift in axis y, usually -0.25 ~ 0.25.
    is_random : boolean
        If True, randomly shift. Default is False.
    row_index col_index and channel_index : int
        Index of row, col and channel, default (0, 1, 2), for theano (1, 2, 0).
    fill_mode : str
        Method to fill missing pixel, default `nearest`, more options `constant`, `reflect` or `wrap`, see `scipy ndimage affine_transform <https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.ndimage.interpolation.affine_transform.html>`__
    cval : float
        Value used for points outside the boundaries of the input if mode='constant'. Default is 0.0.
    order : int
        The order of interpolation. The order has to be in the range 0-5. See ``tl.prepro.affine_transform`` and `scipy ndimage affine_transform <https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.ndimage.interpolation.affine_transform.html>`__

    Returns
    -------
    numpy.array
        A processed image.