human
Complete this python program:
def convert(image, dtype, force_copy=False, uniform=False):
assistant
#Here is the Python code you requested.

    """Convert an image to the requested data-type.
    Warnings are issued in case of precision loss, or when negative values
    are clipped during conversion to unsigned integer types (sign loss).
    Floating point values are expected to be normalized and will be clipped
    to the range [0.0, 1.0] or [-1.0, 1.0] when converting to unsigned or
    signed integers respectively.
    Numbers are not shifted to the negative side when converting from
    unsigned to signed integer types. Negative values will be clipped when
    converting to unsigned integers.
    Parameters
    image : ndarray
    Input image.
    dtype : dtype
    Target data-type.
    force_copy : bool, optional
    Force a copy of the data, irrespective of its current dtype.
    uniform : bool, optional
    Uniformly quantize the floating point range to the integer range.
    By default (uniform=False) floating point values are scaled and
    rounded to the nearest integers, which minimizes back and forth
    conversion errors.
    References
    .. [1] DirectX data conversion rules.
    http://msdn.microsoft.com/en-us/library/windows/desktop/dd607323%28v=vs.85%29.aspx
    .. [2] Data Conversions. In "OpenGL ES 2.0 Specification v2.0.25",
    pp 7-8. Khronos Group, 2010.
    .. [3] Proper treatment of pixels as integers. A.W. Paeth.
    In "Graphics Gems I", pp 249-256. Morgan Kaufmann, 1990.
    .. [4] Dirty Pixels. J. Blinn. In "Jim Blinn\s corner: Dirty Pixels",
    pp 47-57. Morgan Kaufmann, 1998.
    """
    image = np.asarray(image)
    dtypeobj_in = image.dtype
    dtypeobj_out = np.dtype(dtype)
    dtype_in = dtypeobj_in.type
    dtype_out = dtypeobj_out.type
    kind_in = dtypeobj_in.kind
    kind_out = dtypeobj_out.kind
    itemsize_in = dtypeobj_in.itemsize
    itemsize_out = dtypeobj_out.itemsize
    if (dtype_in == dtype_out):
        if force_copy:
            image = image.copy()
        return image
    if (not ((dtype_in in _supported_types) and (dtype_out in _supported_types))):
        raise ValueError('Can    not    convert    from    {}    to    {}.'.format(dtypeobj_in, dtypeobj_out))
    def sign_loss():
        warn('Possible    sign    loss    when    converting    negative    image    of    type    {}    to    positive    image    of    type    {}.'.format(dtypeobj_in, dtypeobj_out))
    def prec_loss():
        warn('Possible    precision    loss    when    converting    from    {}    to    {}'.format(dtypeobj_in, dtypeobj_out))
    def _dtype_itemsize(itemsize, *dtypes):
        return next((dt for dt in dtypes if (np.dtype(dt).itemsize >= itemsize)))
    def _dtype_bits(kind, bits, itemsize=1):
        def compare(x, y, kind='u'):
            if (kind == 'u'):
                return (x <= y)
            else:
                return (x < y)
        s = next((i for i in ((itemsize,) + (2, 4, 8)) if compare(bits, (i * 8), kind=kind)))
        return np.dtype((kind + str(s)))
    def _scale(a, n, m, copy=True):
        'Scale    an    array    of    unsigned/positive    integers    from    `n`    to    `m`    bits.\n\n                                Numbers    can    be    represented    exactly    only    if    `m`    is    a    multiple    of    `n`.\n\n                                Parameters\n                                ----------\n                                a    :    ndarray\n                                                Input    image    array.\n                                n    :    int\n                                                Number    of    bits    currently...