code: def make_bert_classifier_model_fn(optimizer):
      def _bert_classifier_model_fn(features, labels, mode, params):
          """
          Model function for BERTClassifier.
  
          :param features: Dict of feature tensors. Must include the key "input_ids".
          :param labels: Label tensor for training.
          :param mode: 'train', 'eval' or 'infer'.
          :param params: Must include the key "num_classes".
          :return: tf.estimator.EstimatorSpec.
          """
          import tensorflow as tf
          from bigdl.orca.tfpark import ZooOptimizer
  
          output_layer = bert_model(
              features, labels, mode, params
          ).get_pooled_output()
          hidden_size = output_layer.shape[-1].value
          output_weights = tf.get_variable(
              "output_weights",
              [params["num_classes"], hidden_size],
              initializer=tf.truncated_normal_initializer(stddev=0.02),
          )
          output_bias = tf.get_variable(
              "output_bias",
              [params["num_classes"]],
              initializer=tf.zeros_initializer(),
          )
          with tf.variable_scope("loss"):
              if mode == tf.estimator.ModeKeys.TRAIN:
                  output_layer = tf.nn.dropout(
                      output_layer, keep_prob=0.9
                  )
  
              logits = tf.matmul(
                  output_layer, output_weights, transpose_b=True
              )
              logits = tf.nn.bias_add(logits, output_bias)
              probabilities = tf.nn.softmax(logits, axis=-1)
  
              if mode == tf.estimator.ModeKeys.PREDICT:
                  return tf.estimator.EstimatorSpec(
                      mode=mode, predictions=probabilities
                  )
              else:
                  log_probs = tf.nn.log_softmax(logits, axis=-1)
                  one_hot_labels = tf.one_hot(
                      labels,
                      depth=params["num_classes"],
                      dtype=tf.float32,
                  )
                  per_example_loss = -tf.reduce_sum(
                      one_hot_labels * log_probs, axis=-1
                  )
                  loss = tf.reduce_mean(per_example_loss)
                  if mode == tf.estimator.ModeKeys.EVAL:
                      return tf.estimator.EstimatorSpec(
                          mode=mode,
                          predictions=probabilities,
                          loss=loss,
                      )
                  else:
                      train_op = ZooOptimizer(optimizer).minimize(loss)
                      return tf.estimator.EstimatorSpec(
                          mode=mode, train_op=train_op, loss=loss
                      )
  
      return _bert_classifier_model_fn
  
imports: from bigdl.orca.tfpark.text.estimator import *
label_desc: Use image node_id 1 for calling a global function with example usage: make_bert_classifier_model_fn(optimizer) and returns: _bert_classifier_model_fn, tf, tf, tf