code: def _apply_graph_pass(
      mlmodel: _MLModel,
      graph_pass: _AbstractQuantizationPass,
      spec_version: int = _SPECIFICATION_VERSION_IOS_16,
      skip_model_load: bool = False,
      pymil_load_func: Callable = _milproto_to_pymil.load,
  ):
      # Utility function which compresses a Core ML model
      # converts the full precision mlmodel into a pymil program
      model_spec = mlmodel.get_spec()
      specification_version = max(
          model_spec.specificationVersion, spec_version
      )
      prog = _convert_model_spec_to_pymil_prog(
          mlmodel, specification_version, pymil_load_func
      )
  
      # apply compression graph pass
      assert isinstance(
          graph_pass, _AbstractQuantizationPass
      ), "compression pass must be an AbstractQuantizationPass instance"
      graph_pass.apply(prog)
  
      # convert the pymil program back to mlmodel
      compressed_mlmodel = _mil_convert(
          prog,
          convert_to="mlprogram",
          convert_from="milinternal",
          specification_version=specification_version,
          compute_units=mlmodel.compute_unit,
          model_description=model_spec.description,
          skip_model_load=skip_model_load,
      )
      return compressed_mlmodel
  
imports: from collections import OrderedDict
  from typing import Callable, Dict, List, Optional
  import numpy
  from attrs import define, field, validators
  from tqdm import tqdm
  from coremltools import _SPECIFICATION_VERSION_IOS_16
  from coremltools.converters.mil.converter import mil_convert
  from coremltools.converters.mil.frontend.milproto import load
  from coremltools.converters.mil.mil.passes.defs.quantization import AbstractQuantizationPass
  from coremltools.models import MLModel
  from coremltools.optimize.coreml import OptimizationConfig
  from coremltools.optimize.coreml._config import _MetaDataDict
  from ._quantization_passes import WeightDecompressor
  from ._quantization_passes import linear_quantize_weights
  from ._quantization_passes import palettize_weights
  from ._quantization_passes import prune_weights
label_desc: Use image node_id 2 for calling a global function with example usage: _apply_graph_pass(mlmodel, graph_pass, spec_version, skip_model_load, pymil_load_func) and returns: compressed_mlmodel