code: def sg_queue_context(sess=None):
      r
  
      # default session
      sess = tf.get_default_session() if sess is None else sess
  
      # thread coordinator
      coord = tf.train.Coordinator()
      try:
          # start queue thread
          threads = tf.train.start_queue_runners(sess, coord)
          yield
      finally:
          # stop queue thread
          coord.request_stop()
          # wait thread to exit.
          coord.join(threads)
docs: r"""Context helper for queue routines.
  
      Args:
        sess: A session to open queues. If not specified, a new session is created.
  
      Returns:
        None