class_docstr: WIT widget base class for common code between Jupyter and Colab.
docstr: Returns an example selection callback for use with TFMA.
  
  The returned function can be provided as an event handler for a TFMA
  visualization to dynamically load examples matching a selected slice into
  WIT.
  
  Args:
    examples: A list of tf.Examples to filter and use with WIT.
    max_examples: The maximum number of examples to create.
docstr_tok: ["Returns","an","example","selection","callback","for","use","with","TFMA",".","The","returned","function","can","be","provided","as","an","event","handler","for","a","TFMA","visualization","to","dynamically","load","examples","matching","a","selected","slice","into","WIT",".","Args",":","examples",":","A","list","of","tf.Examples","to","filter","and","use","with","WIT",".","max_examples",":","The","maximum","number","of","examples","to","create","."]
code: def create_selection_callback(self, examples, max_examples):
      """Returns an example selection callback for use with TFMA.
  
      The returned function can be provided as an event handler for a TFMA
      visualization to dynamically load examples matching a selected slice into
      WIT.
  
      Args:
        examples: A list of tf.Examples to filter and use with WIT.
        max_examples: The maximum number of examples to create.
      """
  
      def handle_selection(selected):
          def extract_values(feat):
              if feat.HasField("bytes_list"):
                  return [
                      v.decode("utf-8") for v in feat.bytes_list.value
                  ]
              elif feat.HasField("int64_list"):
                  return feat.int64_list.value
              elif feat.HasField("float_list"):
                  return feat.float_list.value
              return None
  
          filtered_examples = []
          for ex in examples:
              if selected["sliceName"] == "Overall":
                  filtered_examples.append(ex)
              else:
                  values = extract_values(
                      ex.features.feature[selected["sliceName"]]
                  )
                  if selected["sliceValue"] in values:
                      filtered_examples.append(ex)
              if len(filtered_examples) == max_examples:
                  break
  
          self.set_examples(filtered_examples)
  
      return handle_selection
  
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 16 for calling the WitWidgetBase obj's underlying member method code with example usage: obj.create_selection_callback(examples, max_examples) and returns: handle_selection, None, unknown, feat, feat