code: def add_multiarray_ndshape_enumeration(
      spec, feature_name, enumerated_shapes
  ):
      """
      Annotate an input or output MLMultiArray feature in a Neural Network spec
      to accommodate a range of shapes.
      Add provided enumerated shapes to the list of shapes already present.
      This method is different from "add_enumerated_multiarray_shapes", which is applicable
      for rank 5 mapping, SBCHW, arrays.
  
      :param spec: MLModel
          The MLModel spec containing the feature
  
      :param feature_name: str
          The name of the feature for which to add shape range
          information. If the feature is not found in the input or output
          descriptions then an exception is thrown
  
      :param enumerated_shapes: List[Tuple(int)]
          list of shapes, where each shape is specified as a tuple of integers.
  
  
      Examples
      --------
      .. sourcecode:: python
  
          >>> import coremltools
          >>> from coremltools.models.neural_network import flexible_shape_utils
          >>> spec = coremltools.utils.load_spec('mymodel.mlmodel')
          >>> # say, the default shape of "my_multiarray_featurename" is (2,3)
          >>> flexible_shape_utils.add_multiarray_ndshape_enumeration(spec, feature_name='my_multiarray_featurename', enumerated_shapes=[(2,4), (2,6)])
  
      :return:
          None. The spec is updated
      """
      if not isinstance(enumerated_shapes, list):
          raise Exception("enumerated_shapes must be a list")
      if len(enumerated_shapes) == 0:
          raise Exception("enumerated_shapes is empty")
  
      feature = _get_feature(spec, feature_name)
      if feature.type.WhichOneof("Type") != "multiArrayType":
          raise Exception(
              "Trying to update shape range for "
              "a non-multiArray feature type"
          )
  
      shape = feature.type.multiArrayType.shape
  
      if (
          feature.type.multiArrayType.WhichOneof("ShapeFlexibility")
          != "enumeratedShapes"
      ):
          feature.type.multiArrayType.ClearField("ShapeFlexibility")
  
      eshape_len = len(
          feature.type.multiArrayType.enumeratedShapes.shapes
      )
  
      # Add default array shape to list of enumerated shapes if enumerated shapes
      # field is currently empty
      if eshape_len == 0:
          fixed_shape = feature.type.multiArrayType.shape
          s = feature.type.multiArrayType.enumeratedShapes.shapes.add()
          s.shape.extend(fixed_shape)
  
      for shape in enumerated_shapes:
          if not isinstance(shape, tuple):
              raise Exception(
                  "An element in 'enumerated_shapes' is not a tuple"
              )
          s = feature.type.multiArrayType.enumeratedShapes.shapes.add()
          s.shape.extend(list(shape))
  
      # Bump up specification version
      spec.specificationVersion = max(
          _MINIMUM_NDARRAY_SPEC_VERSION, spec.specificationVersion
      )
  
imports: from ..utils import _get_feature, _get_nn_layers, _get_input_names
  from ...None import _MINIMUM_FLEXIBLE_SHAPES_SPEC_VERSION
  from ...None import _MINIMUM_NDARRAY_SPEC_VERSION
label_desc: Use image node_id 6 for calling a global function with example usage: add_multiarray_ndshape_enumeration(spec, feature_name, enumerated_shapes) without return types