def update_image_size_range(spec, feature_name, size_range):
    """
    Annotate an input or output Image feature in a neural network spec to
    to accommodate a range of image sizes.

    :param spec: MLModel
        The MLModel spec containing the feature.

    :param feature_name: str
        The name of the Image feature for which to add shape information.
        If the feature is not found in the input or output descriptions then
        an exception is thrown.

    :param size_range: NeuralNetworkImageSizeRange
        A NeuralNetworkImageSizeRange object with the populated image size
        range information.

    Examples
    --------
    .. sourcecode:: python

        import coremltools
        from coremltools.models.neural_network import flexible_shape_utils

        spec = coremltools.utils.load_spec("mymodel.mlmodel")
        img_size_ranges = flexible_shape_utils.NeuralNetworkImageSizeRange()
        img_size_ranges.add_height_range(64, 128)
        img_size_ranges.add_width_range(128, -1)
        flexible_shape_utils.update_image_size_range(
            spec, feature_name="my_multiarray_featurename", size_range=img_size_ranges
        )

    :return:
        None. The spec object is updated
    """
    feature = _get_feature(spec, feature_name)
    _update_image_size_range_for_feature(feature, size_range)

    # Bump up specification version
    spec.specificationVersion = max(
        _MINIMUM_FLEXIBLE_SHAPES_SPEC_VERSION, spec.specificationVersion
    )

    Annotate an input or output Image feature in a neural network spec to
    to accommodate a range of image sizes.

    :param spec: MLModel
        The MLModel spec containing the feature.

    :param feature_name: str
        The name of the Image feature for which to add shape information.
        If the feature is not found in the input or output descriptions then
        an exception is thrown.

    :param size_range: NeuralNetworkImageSizeRange
        A NeuralNetworkImageSizeRange object with the populated image size
        range information.

    Examples
    --------
    .. sourcecode:: python

        import coremltools
        from coremltools.models.neural_network import flexible_shape_utils

        spec = coremltools.utils.load_spec("mymodel.mlmodel")
        img_size_ranges = flexible_shape_utils.NeuralNetworkImageSizeRange()
        img_size_ranges.add_height_range(64, 128)
        img_size_ranges.add_width_range(128, -1)
        flexible_shape_utils.update_image_size_range(
            spec, feature_name="my_multiarray_featurename", size_range=img_size_ranges
        )

    :return:
        None. The spec object is updated
    
coremltools/models/neural_network/flexible_shape_utils.py