class_docstr: WIT widget base class for common code between Jupyter and Colab.
code: def _json_to_tf_examples(self, examples):
      def add_single_feature(feat, value, ex):
          if isinstance(value, integer_types):
              ex.features.feature[feat].int64_list.value.append(value)
          elif isinstance(value, Number):
              ex.features.feature[feat].float_list.value.append(value)
          else:
              ex.features.feature[feat].bytes_list.value.append(
                  value.encode("utf-8")
              )
  
      tf_examples = []
      for json_ex in examples:
          ex = tf.train.Example()
          # JSON examples can be lists of values (for xgboost models for instance),
          # or dicts of key/value pairs.
          if self.config.get("uses_json_list"):
              feature_names = self.config.get("feature_names")
              for i, value in enumerate(json_ex):
                  # If feature names have been provided, use those feature names instead
                  # of list indices for feature name when storing as tf.Example.
                  if feature_names and len(feature_names) > i:
                      feat = feature_names[i]
                  else:
                      feat = str(i)
                  add_single_feature(feat, value, ex)
              tf_examples.append(ex)
          else:
              for feat in json_ex:
                  add_single_feature(feat, json_ex[feat], ex)
              tf_examples.append(ex)
      return tf_examples
  
imports: import base64
  import json
  import googleapiclient.discovery
  import os
  import logging
  import multiprocessing
  import tensorflow
  from IPython import display
  from google.protobuf import json_format
  from numbers import Number
  from oauth2client.client import GoogleCredentials
  from six import ensure_str
  from six import integer_types
  from utils import inference_utils
label_desc: Use image node_id 12 for calling the WitWidgetBase obj's underlying member method code with example usage: obj._json_to_tf_examples(examples) and returns: tf_examples