class_docstr: ``core.Context`` is a simple composition of several component APIs, with the following public
  members:
  
  -  ``.checkpoint``, a :class:`~CheckpointContext`
  -  ``.distributed``, a :class:`~DistributedContext`
  -  ``.preempt``, a :class:`~PreemptContext`
  -  ``.searcher``, a :class:`~SearcherContext`
  -  ``.train``, a :class:`~TrainContext`
  
  ``core.Context`` is a tool for integrating arbitrary distributed tasks into a Determined
  cluster.
  
  You should always use :meth:`core.init() <determined.core.init>` instead of creating a
  core.Context manually.
code: def __exit__(
      self,
      exc_type: Optional[type],
      exc_val: Optional[BaseException],
      exc_tb: Optional[types.TracebackType],
  ) -> None:
      self.close(exc_type, exc_val, exc_tb)
      # Detect some specific exceptions that are part of the user-facing API.
      if isinstance(exc_val, det.InvalidHP):
          self.train.report_early_exit(core.EarlyExitReason.INVALID_HP)
          logger.info(
              "InvalidHP detected during Trial init, converting InvalidHP to exit(0)"
          )
          exit(0)
  
imports: import logging
  import pathlib
  import signal
  import sys
  import threading
  import traceback
  import types
  from typing import Any, Dict, Optional, Union
  import appdirs
  import determined
  from determined import core, tensorboard
  from determined.common import api, constants, storage, util
  from determined.common.api import certs
label_desc: Use image node_id 5 for calling the Context obj's underlying member method code with example usage: obj.__exit__(exc_type, exc_val, exc_tb) without return types