code: def assert_model_is_valid(
      program,
      inputs,
      backend=("neuralnetwork", "fp32"),
      verbose=True,
      expected_output_shapes=None,
      minimum_deployment_target: ct.target = None,
  ):
      """
      Assert Core ML model is valid.
  
      Inputs:
  
      - input: str -> shape tuple. All program input names need to appear in str.
        shape tuple can only contain positive integers.
      """
      if minimum_deployment_target is not None:
          validate_minimum_deployment_target(
              minimum_deployment_target, backend
          )
  
      # Avoid circular import
      from coremltools.converters.mil.testing_reqs import ct
  
      input_dict = dict()
      for name, shape in inputs.items():
          input_dict[name] = np.random.rand(*shape)
  
      mlmodel = ct_convert(
          program,
          source="milinternal",
          convert_to=backend,
          compute_units=ct.ComputeUnit.CPU_ONLY,
          minimum_deployment_target=minimum_deployment_target,
      )
      assert mlmodel is not None
  
      if verbose:
          from coremltools.models.neural_network.printer import (
              print_network_spec,
          )
  
          print_network_spec(mlmodel.get_spec(), style="coding")
  
      if _IS_MACOS and (
          not mlmodel.is_package
          or coremltoolsutils._macos_version() >= (12, 0)
      ):
          prediction = mlmodel.predict(input_dict)
          assert prediction is not None
          if expected_output_shapes is not None:
              for out_name, out_shape in expected_output_shapes.items():
                  assert out_name in prediction
                  assert (
                      out_shape == prediction[out_name].shape
                  ), "{} != {}".format(
                      out_shape, prediction[out_name].shape
                  )
  
imports: import itertools
  import copy
  import os
  from functools import partial
  from pathlib import Path
  from typing import Dict, List, Tuple
  import numpy
  import pytest
  from PIL import Image
  import coremltools
  import coremltools.models.utils
  from coremltools._deps import _IS_MACOS
  from coremltools.converters.mil.mil import Block, Function, Program
  from coremltools.converters.mil.mil.passes.defs.preprocess import NameSanitizer
  from coremltools.converters.mil.mil.passes.defs.quantization import AbstractQuantizationPass
  from coremltools.converters.mil.mil.passes.pass_registry import PASS_REGISTRY
  from coremltools.proto import FeatureTypes_pb2
label_desc: Use image node_id 4 for calling a global function with example usage: assert_model_is_valid(program, inputs, backend, verbose, expected_output_shapes, minimum_deployment_target) without return types