code: def _remove_invalid_keys(input_dict, model):
      # make sure that input_dict does not contain an input name, which
      # is not present in the list of model inputs
      input_dict_keys = list(input_dict.keys())
      model_input_names = set(
          [inp.name for inp in model._spec.description.input]
      )
      for k in input_dict_keys:
          if k not in model_input_names:
              del input_dict[k]
  
imports: from collections.abc import Iterable
  from functools import lru_cache
  import math
  import os
  import shutil
  import subprocess
  import sys
  import tempfile
  from typing import Optional, Union
  import warnings
  import numpy
  import coremltools
  from coremltools import ComputeUnit
  from coremltools.converters.mil.mil.passes.defs.preprocess import NameSanitizer
  from coremltools.proto import Model_pb2
  import coremltools.proto.MIL_pb2
  from .._deps import _HAS_SCIPY
label_desc: Use image node_id 2 for calling a global function with example usage: _remove_invalid_keys(input_dict, model) without return types