code: def compile_and_fit(
      model, image_train, label_train, compile_kwargs, fit_kwargs
  ):
      # Compile the model.
      compile_args = {
          "optimizer": "adam",
          "loss": "sparse_categorical_crossentropy",
          "metrics": ["accuracy"],
      }
      compile_args.update(compile_kwargs)
      model.compile(**compile_args)
  
      # train the model.
      fit_args = {"epochs": 4, "validation_split": 0.1}
      fit_args.update(fit_kwargs)
      model.fit(image_train, label_train, **fit_args)
  
file_path: model-optimization/tensorflow_model_optimization/python/examples/quantization_with_sparsity/keras/mnist_cnn.py
imports: from __future__ import print_function
  from absl import app
  import numpy
  import tensorflow
  from tensorflow_model_optimization.python.core.quantization.keras import quantize
  from tensorflow_model_optimization.python.core.quantization.keras.collab_opts.prune_preserve import default_8bit_prune_preserve_quantize_scheme
  from tensorflow_model_optimization.python.core.sparsity.keras import prune
  from tensorflow_model_optimization.python.core.sparsity.keras import pruning_callbacks
  from tensorflow_model_optimization.python.core.sparsity.keras import pruning_schedule
label_desc: Use image node_id 2 for calling a global function with example usage: compile_and_fit(model, image_train, label_train, compile_kwargs, fit_kwargs) without return types