def transform_shape(shape):
    """
    Transforms a shape to resize an image after that. Shape size must 
    be equal to 2 or 3, otherwise it raises a ValueError.

    Returns:
        A tuple of the same size.

    Raises:
        A ValueError if the shape size is not equal to 2 or 3.

    Example:
        >>> shape = (4850, 650, 3)
        >>> new_shape = transform_shape(shape)
        >>> print(new_shape)
        (5000, 1000, 3)
    """
    if len(shape) < 2 or len(shape) > 3:
        raise ValueError("ERROR: Shape size must be in [2;3]")
    # Create a tuple to store the new shape
    new_shape = tuple()
    for value in shape[:2]:
        # Convert this value to a string
        val = str(value)
        # Get the first two values and store the rest in another 
        # variable
        sup, inf = val[:-3] if val[:-3] != '' else "1", val[-3:]
        if int(inf) > 500:
            sup = str(int(sup)+1)
        new_shape += (int(sup + "000"),)

    # Don't forget the last element (only if it exists)
    if len(shape) == 3:
        new_shape += (shape[2],)

    return new_shape