def shuffle_channels(image, random_state, channels=None):
if image.ndim < <NUM_LIT:3> or image.shape[<NUM_LIT:2>] == <NUM_LIT:1>:<EOL><INDENT>return image<EOL><DEDENT>nb_channels = image.shape[<NUM_LIT:2>]<EOL>all_channels = np.arange(nb_channels)<EOL>is_all_channels = (<EOL>channels is None<EOL>or channels == ia.ALL<EOL>or len(set(all_channels).difference(set(channels))) == <NUM_LIT:0><EOL>)<EOL>if is_all_channels:<EOL><INDENT>channels_perm = random_state.permutation(all_channels)<EOL>return image[..., channels_perm]<EOL><DEDENT>else:<EOL><INDENT>channels_perm = random_state.permutation(channels)<EOL>channels_perm_full = all_channels<EOL>for channel_source, channel_target in zip(channels, channels_perm):<EOL><INDENT>channels_perm_full[channel_source] = channel_target<EOL><DEDENT>return image[..., channels_perm_full]<EOL><DEDENT>
Randomize the order of (color) channels in an image.

dtype support::

    * ``uint8``: yes; fully tested
    * ``uint16``: yes; indirectly tested (1)
    * ``uint32``: yes; indirectly tested (1)
    * ``uint64``: yes; indirectly tested (1)
    * ``int8``: yes; indirectly tested (1)
    * ``int16``: yes; indirectly tested (1)
    * ``int32``: yes; indirectly tested (1)
    * ``int64``: yes; indirectly tested (1)
    * ``float16``: yes; indirectly tested (1)
    * ``float32``: yes; indirectly tested (1)
    * ``float64``: yes; indirectly tested (1)
    * ``float128``: yes; indirectly tested (1)
    * ``bool``: yes; indirectly tested (1)

    - (1) Indirectly tested via ``ChannelShuffle``.

Parameters
----------
image : (H,W,[C]) ndarray
    Image of any dtype for which to shuffle the channels.

random_state : numpy.random.RandomState
    The random state to use for this shuffling operation.

channels : None or imgaug.ALL or list of int, optional
    Which channels are allowed to be shuffled with each other.
    If this is ``None`` or ``imgaug.ALL``, then all channels may be shuffled. If it is a list of integers,
    then only the channels with indices in that list may be shuffled. (Values start at 0. All channel indices in
    the list must exist in each image.)

Returns
-------
ndarray
    The input image with shuffled channels.