code: def _make_coreml_input_features(
      graph,
      onnx_coreml_input_shape_map,
      disable_coreml_rank5_mapping=False,
  ):  # type: (...) -> Sequence[Tuple[Text, datatypes.Array]]
      """
      If "disable_coreml_rank5_mapping" is False, then:
  
      ONNX shapes to CoreML static shapes mapping
      length==1: [C]
      length==2: [B,C]
      length==3: [C,H,W] or [Seq,B,C]
      length==4: [B,C,H,W]
  
      If "disable_coreml_rank5_mapping" is True, then
      onnx shapes are mapped "as is" to CoreML.
      """
      inputs = graph.inputs
      op_types = graph.blob_to_op_type
      features = []
      for input_ in inputs:
          shape = input_[2]
          if disable_coreml_rank5_mapping:
              if len(shape) > 5:
                  raise ValueError(
                      "ONNX input %s has a rank greater than 5, which is not supported in CoreML framework"
                      % str(input_[0])
                  )
              else:
                  features.append(
                      (str(input_[0]), datatypes.Array(*shape))
                  )
              continue
  
          if (
              USE_SHAPE_MAPPING
              and input_[0] in onnx_coreml_input_shape_map
          ):
              mapp = onnx_coreml_input_shape_map[input_[0]]
              if len(mapp) != len(shape):
                  raise ValueError(
                      "Incorrect value in onnx_coreml_input_shape_map argument"
                  )
              graph.onnx_coreml_shape_mapping[input_[0]] = mapp
              coreml_shape = [1, 1, 1]
              for i in range(3):
                  if (i + 2) in mapp:
                      coreml_shape[i] = shape[mapp.index(i + 2)]
              shape = coreml_shape
          else:
              if len(shape) == 0:
                  shape = [1, 1, 1]
              elif len(shape) == 1:
                  # assume [C]
                  if USE_SHAPE_MAPPING:
                      graph.onnx_coreml_shape_mapping[input_[0]] = [2]
              elif len(shape) == 2:
                  # assume [Batch,C]
                  shape = [shape[1]]
                  if USE_SHAPE_MAPPING:
                      graph.onnx_coreml_shape_mapping[input_[0]] = [
                          1,
                          2,
                      ]
              elif len(shape) == 3:
                  # assume [C,H,W] unless its connected an op that bestows another mapping
                  if (
                      input_[0] in op_types
                      and len(op_types[input_[0]]) == 1
                  ):
                      if (
                          str(op_types[input_[0]][0])
                          in _SEQUENCE_LAYERS_REGISTRY
                      ):
                          # (Seq,B,C)
                          shape = [shape[2]]
                          if USE_SHAPE_MAPPING:
                              graph.onnx_coreml_shape_mapping[
                                  input_[0]
                              ] = [0, 1, 2]
                      elif str(op_types[input_[0]][0]) in [
                          "MaxPool",
                          "AveragePool",
                          "BatchNormalization",
                          "GlobalAveragePool",
                          "GlobalLpPool",
                          "GlobalMaxPool",
                          "InstanceNormalization",
                          "LRN",
                          "LpPool",
                          "Conv",
                          "ConvTranspose",
                      ]:
                          # (B,C,W)
                          shape = [shape[1], 1, shape[2]]
                          if USE_SHAPE_MAPPING:
                              graph.onnx_coreml_shape_mapping[
                                  input_[0]
                              ] = [1, 2, 4]
                      else:
                          if USE_SHAPE_MAPPING:
                              graph.onnx_coreml_shape_mapping[
                                  input_[0]
                              ] = [2, 3, 4]
                  else:
                      if USE_SHAPE_MAPPING:
                          graph.onnx_coreml_shape_mapping[input_[0]] = [
                              2,
                              3,
                              4,
                          ]
              elif len(shape) == 4:  # (B,C,H,W) --> (C,H,W)
                  shape = shape[1:]
                  if USE_SHAPE_MAPPING:
                      graph.onnx_coreml_shape_mapping[input_[0]] = [
                          1,
                          2,
                          3,
                          4,
                      ]
              else:
                  raise ValueError(
                      "CoreML input cannot be more than rank 4. Input shape: %s, input: '%s' "
                      % (str(shape), str(input_[0]))
                  )
          features.append((str(input_[0]), datatypes.Array(*shape)))
      return features
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from typing import Text, Union, Optional, Dict, Any, Iterable, Sequence, Callable, List
  import numpy
  from coremltools._deps import _HAS_ONNX
  from coremltools.models.neural_network import NeuralNetworkBuilder
  from coremltools.models import datatypes, MLModel
  from coremltools.proto import FeatureTypes_pb2
  from coremltools import _MINIMUM_CUSTOM_LAYER_SPEC_VERSION
  from coremltools import _MINIMUM_CUSTOM_MODEL_SPEC_VERSION
  from coremltools import _MINIMUM_NDARRAY_SPEC_VERSION
  from coremltools import __version__
  from coremltools.models import _METADATA_VERSION, _METADATA_SOURCE
  from typing import Tuple
  from ._operators import _convert_node, _SEQUENCE_LAYERS_REGISTRY, _ONNX_NODE_REGISTRY, _add_const_inputs_if_required
  from ._operators_nd import _ONNX_NODE_REGISTRY_ND, _convert_node_nd
  from ._graph import Graph, EdgeInfo, Transformer
  from ._transformers import ConvAddFuser, DropoutRemover, ReshapeInitTensorFuser, BNBroadcastedMulFuser, BNBroadcastedAddFuser, PixelShuffleFuser, OutputRenamer, AddModelInputsOutputs, ConstantsToInitializers, ImageScalerRemover, ShapeOpRemover, ConstantRemover, ConstantFillToInitializers, ReshapeTransposeReshape_pattern1, CastOpRemover, DeadCodeElimination, PaddingOpRemover
  from coremltools.converters.mil.backend.nn.passes.mlmodel_passes import remove_disconnected_layers, transform_conv_crop
  from ._error_utils import ErrorHandling
  from ._graph_viz import plot_graph
label_desc: Use image node_id 1 for calling a global function with example usage: _make_coreml_input_features(graph, onnx_coreml_input_shape_map, disable_coreml_rank5_mapping) and returns: features