src/transformers/models/mobilevit/image_processing_mobilevit.py/flip_channel_order
def flip_channel_order(image: np.ndarray, data_format: Optional[ChannelDimension]) -> np.ndarray:
    """
    Flip the color channels from RGB to BGR or vice versa.

    Args:
        image (`np.ndarray`):
            The image, represented as a numpy array.
        data_format (`ChannelDimension`, *`optional`*):
            The channel dimension format of the image. If not provided, it will be the same as the input image.

    Returns:
        `np.ndarray`: The image with the flipped color channels.
    """
    input_data_format = infer_channel_dimension_format(image)

    if input_data_format == ChannelDimension.LAST:
        image = image[..., ::-1]
    elif input_data_format == ChannelDimension.FIRST:
        image = image[:, ::-1, ...]
    else:
        raise ValueError(f"Invalid input channel dimension format: {input_data_format}")

    if data_format is not None:
        image = to_channel_dimension_format(image, data_format)

    return image