def convert_to_network(x: np.ndarray, net_size: tuple[int, int], clip_min: float, clip_max: float) -> np.ndarray:
    """
    Convert image to network format.

    :param x: Input image.
    :param net_size: The resolution to resize to in (w, h).
    :param clip_min: Minimum value of an example.
    :param clip_max: Maximum value of an example.
    """
    import cv2

    if net_size is not None:
        x = cv2.resize(x, net_size)
    x = np.clip(x, 0, 1)
    x = x * (clip_max - clip_min) + clip_min
    if len(x.shape) < 3:
        x = x[:, :, np.newaxis]
    return x

    Convert image to network format.

    :param x: Input image.
    :param net_size: The resolution to resize to in (w, h).
    :param clip_min: Minimum value of an example.
    :param clip_max: Maximum value of an example.
    
art/attacks/evasion/graphite/utils.py