code: def _get_debug_context(debug_port, debug_args, debugger_path):
          
          if debug_port and debugger_path:
              try:
                  debugger = Path(debugger_path).resolve(strict=True)
              except OSError as error:
                  if error.errno == errno.ENOENT:
                      raise DebugContextException("'{}' could not be found.".format(debugger_path))
                  else:
                      raise error
  
              # We turn off pylint here due to https://github.com/PyCQA/pylint/issues/1660
              if not debugger.is_dir():  # pylint: disable=no-member
                  raise DebugContextException("'{}' should be a directory with the debugger in it.".format(debugger_path))
              debugger_path = str(debugger)
  
          return DebugContext(debug_port=debug_port, debug_args=debug_args, debugger_path=debugger_path)
docs: Creates a DebugContext if the InvokeContext is in a debugging mode
  
          Parameters
          ----------
          debug_port int
               Port to bind the debugger to
          debug_args str
              Additional arguments passed to the debugger
          debugger_path str
              Path to the directory of the debugger to mount on Docker
  
          Returns
          -------
          samcli.commands.local.lib.debug_context.DebugContext
              Object representing the DebugContext
  
          Raises
          ------
          samcli.commands.local.cli_common.user_exceptions.DebugContext
              When the debugger_path is not valid