code: def maybe_with_graph(graph=None, create_if_none=True):
    
    if tf.executing_eagerly():
      yield None
    else:
      if graph is None and create_if_none:
        graph = tf.Graph()
  
      if graph is None:
        yield None
      else:
        with graph.as_default():
          yield graph
docs: Eager-compatible Graph().as_default() yielding the graph.