class_docstr: WIT widget base class for common code between Jupyter and Colab.
docstr: Constructor for WitWidgetBase.
  
  Args:
    config_builder: WitConfigBuilder object containing settings for WIT.
docstr_tok: ["Constructor","for","WitWidgetBase",".","Args",":","config_builder",":","WitConfigBuilder","object","containing","settings","for","WIT","."]
code: def __init__(self, config_builder):
      """Constructor for WitWidgetBase.
  
      Args:
        config_builder: WitConfigBuilder object containing settings for WIT.
      """
      tf.get_logger().setLevel(logging.WARNING)
      config = config_builder.build()
      copied_config = dict(config)
      self.estimator_and_spec = (
          dict(config.get("estimator_and_spec"))
          if "estimator_and_spec" in config
          else {}
      )
      self.compare_estimator_and_spec = (
          dict(config.get("compare_estimator_and_spec"))
          if "compare_estimator_and_spec" in config
          else {}
      )
      if "estimator_and_spec" in copied_config:
          del copied_config["estimator_and_spec"]
      if "compare_estimator_and_spec" in copied_config:
          del copied_config["compare_estimator_and_spec"]
  
      self.custom_predict_fn = config.get("custom_predict_fn")
      self.compare_custom_predict_fn = config.get(
          "compare_custom_predict_fn"
      )
      self.custom_distance_fn = config.get("custom_distance_fn")
      self.adjust_prediction_fn = config.get("adjust_prediction")
      self.compare_adjust_prediction_fn = config.get(
          "compare_adjust_prediction"
      )
      self.adjust_example_fn = config.get("adjust_example")
      self.compare_adjust_example_fn = config.get(
          "compare_adjust_example"
      )
      self.adjust_attribution_fn = config.get("adjust_attribution")
      self.compare_adjust_attribution_fn = config.get(
          "compare_adjust_attribution"
      )
  
      if "custom_predict_fn" in copied_config:
          del copied_config["custom_predict_fn"]
      if "compare_custom_predict_fn" in copied_config:
          del copied_config["compare_custom_predict_fn"]
      if "custom_distance_fn" in copied_config:
          del copied_config["custom_distance_fn"]
          copied_config["uses_custom_distance_fn"] = True
      if "adjust_prediction" in copied_config:
          del copied_config["adjust_prediction"]
      if "compare_adjust_prediction" in copied_config:
          del copied_config["compare_adjust_prediction"]
      if "adjust_example" in copied_config:
          del copied_config["adjust_example"]
      if "compare_adjust_example" in copied_config:
          del copied_config["compare_adjust_example"]
      if "adjust_attribution" in copied_config:
          del copied_config["adjust_attribution"]
      if "compare_adjust_attribution" in copied_config:
          del copied_config["compare_adjust_attribution"]
  
      examples = copied_config.pop("examples")
      self.config = copied_config
      self.set_examples(examples)
  
      # This tracks whether mutant inference is running in order to
      # skip calling for explanations for CAIP models when inferring
      # for mutant inference, for performance reasons.
      self.running_mutant_infer = False
  
      # If using AI Platform for prediction, set the correct custom prediction
      # functions.
      if self.config.get("use_aip"):
          self.custom_predict_fn = self._predict_aip_model
      if self.config.get("compare_use_aip"):
          self.compare_custom_predict_fn = (
              self._predict_aip_compare_model
          )
  
      # If using JSON input (not Example protos) and a custom predict
      # function, then convert examples to JSON before sending to the
      # custom predict function.
      if self.config.get("uses_json_input"):
          if (
              self.custom_predict_fn is not None
              and not self.config.get("use_aip")
          ):
              user_predict = self.custom_predict_fn
  
              def wrapped_custom_predict_fn(examples):
                  return user_predict(
                      self._json_from_tf_examples(examples)
                  )
  
              self.custom_predict_fn = wrapped_custom_predict_fn
          if (
              self.compare_custom_predict_fn is not None
              and not self.config.get("compare_use_aip")
          ):
              compare_user_predict = self.compare_custom_predict_fn
  
              def wrapped_compare_custom_predict_fn(examples):
                  return compare_user_predict(
                      self._json_from_tf_examples(examples)
                  )
  
              self.compare_custom_predict_fn = (
                  wrapped_compare_custom_predict_fn
              )
  
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 1 to create a new WitWidgetBase object from inherited base classes: object with example: obj = WitWidgetBase(config_builder)