class_docstr: Context manager to defer exceptions from imports.
  
  Catches :exc:`ImportError` and :exc:`SyntaxError`.
  If any exception is caught, this class raises an :exc:`ImportError` when being checked.
class_docstr_tok: ["Context","manager","to","defer","exceptions","from","imports",".","Catches",":","exc",":","`","ImportError","`","and",":","exc",":","`","SyntaxError","`",".","If","any","exception","is","caught",",","this","class","raises","an",":","exc",":","`","ImportError","`","when","being","checked","."]
docstr: Exit the context manager.
  
  Args:
      exc_type:
          Raised exception type. :obj:`None` if nothing is raised.
      exc_value:
          Raised exception object. :obj:`None` if nothing is raised.
      traceback:
          Associated traceback. :obj:`None` if nothing is raised.
  
  Returns:
      :obj:`None` if nothing is deferred, otherwise :obj:`True`.
      :obj:`True` will suppress any exceptions avoiding them from propagating.
docstr_tok: ["Exit","the","context","manager",".","Args",":","exc_type",":","Raised","exception","type",".",":","obj",":","`","None","`","if","nothing","is","raised",".","exc_value",":","Raised","exception","object",".",":","obj",":","`","None","`","if","nothing","is","raised",".","traceback",":","Associated","traceback",".",":","obj",":","`","None","`","if","nothing","is","raised",".","Returns",":",":","obj",":","`","None","`","if","nothing","is","deferred",",","otherwise",":","obj",":","`","True","`",".",":","obj",":","`","True","`","will","suppress","any","exceptions","avoiding","them","from","propagating","."]
code: def __exit__(
      self,
      exc_type: Optional[Type[Exception]],
      exc_value: Optional[Exception],
      traceback: Optional[TracebackType],
  ) -> Optional[bool]:
      """Exit the context manager.
  
      Args:
          exc_type:
              Raised exception type. :obj:`None` if nothing is raised.
          exc_value:
              Raised exception object. :obj:`None` if nothing is raised.
          traceback:
              Associated traceback. :obj:`None` if nothing is raised.
  
      Returns:
          :obj:`None` if nothing is deferred, otherwise :obj:`True`.
          :obj:`True` will suppress any exceptions avoiding them from propagating.
  
      """
      if isinstance(exc_value, (ImportError, SyntaxError)):
          if isinstance(exc_value, ImportError):
              message = (
                  "Tried to import '{}' but failed. Please make sure that the package is "
                  "installed correctly to use this feature. Actual error: {}."
              ).format(exc_value.name, exc_value)
          elif isinstance(exc_value, SyntaxError):
              message = (
                  "Tried to import a package but failed due to a syntax error in {}. Please "
                  "make sure that the Python version is correct to use this feature. Actual "
                  "error: {}."
              ).format(exc_value.filename, exc_value)
          else:
              assert False
  
          self._deferred = (exc_value, message)
          return True
      return None
  
file_path: optuna/optuna/_imports.py
imports: import importlib
  import types
  from types import TracebackType
  from typing import Any
  from typing import Optional
  from typing import Tuple
  from typing import Type
label_desc: Use image node_id 3 for calling the _DeferredImportExceptionContextManager obj's underlying member method code with example usage: obj.__exit__(exc_type, exc_value, traceback) and returns: None, True