class_docstr: Evaluate a fixed TensorFlow graph repeatedly, safely, efficiently.
  
  Extend this class to create a particular kind of op evaluator, like an
  image encoder. In `initialize_graph`, create an appropriate TensorFlow
  graph with placeholder inputs. In `run`, evaluate this graph and
  return its result. This class will manage a singleton graph and
  session to preserve memory usage, and will ensure that this graph and
  session do not interfere with other concurrent sessions.
  
  A subclass of this class offers a threadsafe, highly parallel Python
  entry point for evaluating a particular TensorFlow graph.
  
  Example usage:
  
      class FluxCapacitanceEvaluator(PersistentOpEvaluator):
        """Compute the flux capacitance required for a system.
  
        Arguments:
          x: Available power input, as a `float`, in jigawatts.
  
        Returns:
          A `float`, in nanofarads.
        """
  
        def initialize_graph(self):
          self._placeholder = tf.placeholder(some_dtype)
          self._op = some_op(self._placeholder)
  
        def run(self, x):
          return self._op.eval(feed_dict: {self._placeholder: x})
  
      evaluate_flux_capacitance = FluxCapacitanceEvaluator()
  
      for x in xs:
        evaluate_flux_capacitance(x)
docstr: Initialize the graph and session, if this has not yet been done.
docstr_tok: ["Initialize","the","graph","and","session",",","if","this","has","not","yet","been","done","."]
code: def _lazily_initialize(self):
      """Initialize the graph and session, if this has not yet been done."""
      # TODO(nickfelt): remove on-demand imports once dep situation is fixed.
      import tensorflow.compat.v1 as tf
  
      with self._initialization_lock:
          if self._session:
              return
          graph = tf.Graph()
          with graph.as_default():
              self.initialize_graph()
          # Don't reserve GPU because libpng can't run on GPU.
          config = tf.ConfigProto(device_count={"GPU": 0})
          self._session = tf.Session(graph=graph, config=config)
  
imports: import threading
label_desc: Use image node_id 2 for calling the PersistentOpEvaluator obj's underlying member method code with example usage: obj._lazily_initialize() without return types