class_docstr: Helper class for managing the run/training loop.
  
  The context will hide the implementation details of a basic run/training loop.
  It will set things up properly, tell if run should be stopped, and then cleans up.
  User should call update periodically and use should_stop to determine if run should be stopped.
  
  Args:
      submit_config: The SubmitConfig that is used for the current run.
      config_module: (deprecated) The whole config module that is used for the current run.
class_docstr_tok: ["Helper","class","for","managing","the","run\/training","loop",".","The","context","will","hide","the","implementation","details","of","a","basic","run\/training","loop",".","It","will","set","things","up","properly",",","tell","if","run","should","be","stopped",",","and","then","cleans","up",".","User","should","call","update","periodically","and","use","should_stop","to","determine","if","run","should","be","stopped",".","Args",":","submit_config",":","The","SubmitConfig","that","is","used","for","the","current","run",".","config_module",":","(","deprecated",")","The","whole","config","module","that","is","used","for","the","current","run","."]
docstr: Close the context and clean up.
  Should only be called once.
docstr_tok: ["Close","the","context","and","clean","up",".","Should","only","be","called","once","."]
code: def close(self) -> None:
      """Close the context and clean up.
      Should only be called once."""
      if not self.has_closed:
          # update the run.txt with stopping time
          self.run_txt_data[
              "stop_time"
          ] = datetime.datetime.now().isoformat(sep=" ")
          with open(
              os.path.join(self.submit_config.run_dir, "run.txt"), "w"
          ) as f:
              pprint.pprint(
                  self.run_txt_data,
                  stream=f,
                  indent=4,
                  width=200,
                  compact=False,
              )
          self.has_closed = True
  
          # detach the global singleton
          global _run_context
          if _run_context is self:
              _run_context = None
  
file_path: insightface/reconstruction/ostec/external/stylegan2/dnnlib/submission/run_context.py
imports: import datetime
  import os
  import pprint
  import time
  import types
  from typing import Any
  from .None import submit
label_desc: Use image node_id 9 for calling the RunContext obj's underlying member method code with example usage: obj.close() without return types