code: def make_classifier_input_fn(
      feature_spec, n_classes=2, label_vocabulary=None
  ):
      """Train input function.
  
      Args:
        feature_spec: a dictionary mapping feature_name to Tensor or SparseTensor.
        n_classes: set for multiclass.
        label_vocabulary: (Optional) Label vocabulary to use for labels.
  
      Returns:
        A function.
      """
  
      def _input_fn():
          """Example-based input function."""
  
          english_label = (
              label_vocabulary[1] if label_vocabulary else 1.0
          )
          chinese_label = (
              label_vocabulary[0] if label_vocabulary else 0.0
          )
          if n_classes > 2:
              # For multi-class labels, English is class 0, Chinese is class 1.
              chinese_label = (
                  label_vocabulary[1] if label_vocabulary else 1
              )
              english_label = (
                  label_vocabulary[0] if label_vocabulary else 0
              )
  
          serialized_examples = [
              x.SerializeToString()
              for x in [
                  util.make_example(
                      age=1.0, language="english", label=english_label
                  ),
                  util.make_example(
                      age=2.0, language="english", label=english_label
                  ),
                  util.make_example(
                      age=3.0, language="chinese", label=chinese_label
                  ),
                  util.make_example(
                      age=4.0, language="chinese", label=chinese_label
                  ),
              ]
          ]
          features = tf.io.parse_example(
              serialized=serialized_examples, features=feature_spec
          )
          labels = features.pop("label")
          if n_classes > 2 and not label_vocabulary:
              labels = tf.sparse.to_dense(labels, default_value=-1)
  
          return features, labels
  
      return _input_fn
  
file_path: model-analysis/tensorflow_model_analysis/eval_saved_model/example_trainers/util.py
imports: import tensorflow
  from tensorflow_model_analysis.eval_saved_model import export
  from tensorflow_model_analysis.eval_saved_model import util
label_desc: Use image node_id 2 for calling a global function with example usage: make_classifier_input_fn(feature_spec, n_classes, label_vocabulary) and returns: _input_fn, features,  labels