code: def quantize_annotate_model(to_annotate):
      """Annotate a `tf.keras` model to be quantized.
  
      This function does not actually quantize the model. It merely specifies
      that the model needs to be quantized. `quantize_apply` can then be used
      to quantize the model.
  
      This function is intended to be used in conjunction with the
      `quantize_annotate_layer` API. Otherwise, it is simpler to use
      `quantize_model`.
  
      Annotate a model while overriding the default behavior for a layer:
  
      ```python
      quantize_config = MyDenseQuantizeConfig()
  
      model = quantize_annotate_model(
        keras.Sequential([
          layers.Dense(10, activation='relu', input_shape=(100,)),
          quantize_annotate_layer(
              layers.Dense(2, activation='sigmoid'),
              quantize_config=quantize_config)
        ]))
  
      # The first Dense layer gets quantized with the default behavior,
      # but the second layer uses `MyDenseQuantizeConfig` for quantization.
      quantized_model = quantize_apply(model)
      ```
  
      Note that this function removes the optimizer from the original model.
  
      Args:
        to_annotate: `tf.keras` model which needs to be quantized.
  
      Returns:
        New tf.keras model with each layer in the model wrapped with
        `QuantizeAnnotate`. The new model preserves weights from the original
        model.
  
      Raises:
        ValueError: if the model cannot be annotated.
      """
      if to_annotate is None:
          raise ValueError("`to_annotate` cannot be None")
  
      if not isinstance(to_annotate, keras.Model):
          raise ValueError(
              "`to_annotate` can only be a `tf.keras.Model` instance. Use "
              "the `quantize_annotate_layer` API to handle individual layers. "
              "You passed an instance of type: {input}.".format(
                  input=to_annotate.__class__.__name__
              )
          )
  
      if (
          not isinstance(to_annotate, keras.Sequential)
          and not to_annotate._is_graph_network
      ):  # pylint: disable=protected-access
          raise ValueError(
              "`to_annotate` can only either be a tf.keras Sequential or "
              "Functional model."
          )
  
      def _add_quant_wrapper(layer):
          """Add annotation wrapper."""
          # Already annotated layer. No need to wrap.
          if isinstance(layer, quantize_annotate_mod.QuantizeAnnotate):
              return layer
  
          if isinstance(layer, tf.keras.layers.Lambda):
              warnings.warn(
                  "Lambda layers are not supported by automatic model annotation "
                  "because the internal functionality cannot always be determined by "
                  "serialization alone. We recommend that you make a custom layer "
                  "and add a custom QuantizeConfig for it instead. This layer will not "
                  "be quantized which may lead to unexpected results."
              )
              return layer
  
          if isinstance(layer, tf.keras.Model):
              raise ValueError(
                  "Quantizing a tf.keras Model inside another tf.keras Model is not supported."
              )
  
          return quantize_annotate_mod.QuantizeAnnotate(layer)
  
      return keras.models.clone_model(
          to_annotate,
          input_tensors=None,
          clone_function=_add_quant_wrapper,
      )
  
imports: import warnings
  import tensorflow
  from tensorflow_model_optimization.python.core.keras import metrics
  from tensorflow_model_optimization.python.core.quantization.keras import quantize_annotate
  from tensorflow_model_optimization.python.core.quantization.keras import quantize_aware_activation
  from tensorflow_model_optimization.python.core.quantization.keras import quantize_config
  from tensorflow_model_optimization.python.core.quantization.keras import quantize_layer
  from tensorflow_model_optimization.python.core.quantization.keras import quantize_wrapper
  from tensorflow_model_optimization.python.core.quantization.keras import quantizers
  from tensorflow_model_optimization.python.core.quantization.keras import utils
  from tensorflow_model_optimization.python.core.quantization.keras.default_8bit import default_8bit_quantize_registry
  from tensorflow_model_optimization.python.core.quantization.keras.default_8bit import default_8bit_quantize_scheme
  from tensorflow_model_optimization.python.core.quantization.keras.experimental.default_n_bit import default_n_bit_quantize_registry
label_desc: Use image node_id 3 for calling a global function with example usage: quantize_annotate_model(to_annotate) and returns: keras, quantize_annotate_mod, layer, layer