class_docstr: Training helper that restores from checkpoint and creates session.
  
  This class is a small wrapper that takes care of session creation and
  checkpoint recovery. It also provides functions that to facilitate
  coordination among multiple training threads or processes.
  
  * Checkpointing trained variables as the training progresses.
  * Initializing variables on startup, restoring them from the most recent
    checkpoint after a crash, or wait for checkpoints to become available.
  
  ### Usage:
  
  ```python
  with tf.Graph().as_default():
     ...add operations to the graph...
    # Create a SessionManager that will checkpoint the model in '/tmp/mydir'.
    sm = SessionManager()
    sess = sm.prepare_session(master, init_op, saver, checkpoint_dir)
    # Use the session to train the graph.
    while True:
      sess.run(<my_train_op>)
  ```
  
  `prepare_session()` initializes or restores a model. It requires `init_op`
  and `saver` as an argument.
  
  A second process could wait for the model to be ready by doing the following:
  
  ```python
  with tf.Graph().as_default():
     ...add operations to the graph...
    # Create a SessionManager that will wait for the model to become ready.
    sm = SessionManager()
    sess = sm.wait_for_session(master)
    # Use the session to train the graph.
    while True:
      sess.run(<my_train_op>)
  ```
  
  `wait_for_session()` waits for a model to be initialized by other processes.
class_docstr_tok: ["Training","helper","that","restores","from","checkpoint","and","creates","session",".","This","class","is","a","small","wrapper","that","takes","care","of","session","creation","and","checkpoint","recovery",".","It","also","provides","functions","that","to","facilitate","coordination","among","multiple","training","threads","or","processes",".","*","Checkpointing","trained","variables","as","the","training","progresses",".","*","Initializing","variables","on","startup",",","restoring","them","from","the","most","recent","checkpoint","after","a","crash",",","or","wait","for","checkpoints","to","become","available",".","#","#","#","Usage",":","``","`","python","with","tf.Graph","(",")",".as_default","(",")",":","...","add","operations","to","the","graph","...","#","Create","a","SessionManager","that","will","checkpoint","the","model","in","'\/tmp\/mydir","'",".","sm","=","SessionManager","(",")","sess","=","sm.prepare_session","(","master",",","init_op",",","saver",",","checkpoint_dir",")","#","Use","the","session","to","train","the","graph",".","while","True",":","sess.run","(","<","my_train_op",">",")","``","`","`","prepare_session","(",")","`","initializes","or","restores","a","model",".","It","requires","`","init_op","`","and","`","saver","`","as","an","argument",".","A","second","process","could","wait","for","the","model","to","be","ready","by","doing","the","following",":","``","`","python","with","tf.Graph","(",")",".as_default","(",")",":","...","add","operations","to","the","graph","...","#","Create","a","SessionManager","that","will","wait","for","the","model","to","become","ready",".","sm","=","SessionManager","(",")","sess","=","sm.wait_for_session","(","master",")","#","Use","the","session","to","train","the","graph",".","while","True",":","sess.run","(","<","my_train_op",">",")","``","`","`","wait_for_session","(",")","`","waits","for","a","model","to","be","initialized","by","other","processes","."]
docstr: Checks if the model is ready or not.
  
  Args:
    sess: A `Session`.
  
  Returns:
    A tuple (is_ready, msg), where is_ready is True if ready and False
    otherwise, and msg is `None` if the model is ready, a `String` with the
    reason why it is not ready otherwise.
docstr_tok: ["Checks","if","the","model","is","ready","or","not",".","Args",":","sess",":","A","`","Session","`",".","Returns",":","A","tuple","(","is_ready",",","msg",")",",","where","is_ready","is","True","if","ready","and","False","otherwise",",","and","msg","is","`","None","`","if","the","model","is","ready",",","a","`","String","`","with","the","reason","why","it","is","not","ready","otherwise","."]
code: def _model_ready(
      self, sess: session.Session
  ) -> Tuple[bool, Optional[str]]:
      """Checks if the model is ready or not.
  
      Args:
        sess: A `Session`.
  
      Returns:
        A tuple (is_ready, msg), where is_ready is True if ready and False
        otherwise, and msg is `None` if the model is ready, a `String` with the
        reason why it is not ready otherwise.
      """
      return _ready(self._ready_op, sess, "Model not ready")
  
imports: import time
  from typing import Optional, Tuple
  import numpy
  from tensorflow.python.checkpoint import checkpoint_management
  from tensorflow.python.client import session
  from tensorflow.python.distribute import distribute_lib
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.training import saver
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 7 for calling the SessionManager obj's underlying member method code with example usage: obj._model_ready(sess) and returns: _ready