human
What is a the Python program you requested given the following:
I am working on the file "00_Miscellaneous/model_optimisation/Tutorial - TensorFlow Model Optimisation for Serving - MNIST.ipynb".
The first task is:
1.2.2 Create Custom Estimator
Can you write Python program for it?
assistant
#Here is the Python program you requested.

def create_estimator(params, run_config):

    # evaluation metric_fn
    def _metric_fn(labels, predictions):

        metrics = {}
        pred_class = predictions['class_ids']
        metrics['micro_accuracy'] = tf.metrics.mean_per_class_accuracy(
            labels=labels, predictions=pred_class, num_classes=NUM_CLASSES
        )

        return metrics

    mnist_classifier = tf.estimator.Estimator(
        model_fn=model_fn, params=params, config=run_config)

    mnist_classifier = tf.contrib.estimator.add_metrics(
        estimator=mnist_classifier, metric_fn=_metric_fn)
    
    return mnist_classifier