code: def check_resume(args: argparse.Namespace, output_folder: str) -> bool:
      
      resume_training = False
      training_state_dir = os.path.join(output_folder, C.TRAINING_STATE_DIRNAME)
      if os.path.exists(output_folder):
          if args.overwrite_output:
              logger.info("Removing existing output folder %s.", output_folder)
              shutil.rmtree(output_folder)
              os.makedirs(output_folder)
          elif os.path.exists(training_state_dir):
              old_args = vars(arguments.load_args(os.path.join(output_folder, C.ARGS_STATE_NAME)))
              arg_diffs = _dict_difference(vars(args), old_args) | _dict_difference(old_args, vars(args))
              # Remove args that may differ without affecting the training.
              arg_diffs -= set(C.ARGS_MAY_DIFFER)
              # allow different device-ids provided their total count is the same
              if 'device_ids' in arg_diffs and len(old_args['device_ids']) == len(vars(args)['device_ids']):
                  arg_diffs.discard('device_ids')
              if not arg_diffs:
                  resume_training = True
              else:
                  # We do not have the logger yet
                  logger.error("Mismatch in arguments for training continuation.")
                  logger.error("Differing arguments: %s.", ", ".join(arg_diffs))
                  sys.exit(1)
          elif os.path.exists(os.path.join(output_folder, C.PARAMS_BEST_NAME)):
              logger.error("Refusing to overwrite model folder %s as it seems to contain a trained model.", output_folder)
              sys.exit(1)
          else:
              logger.info("The output folder %s already exists, but no training state or parameter file was found. "
                          "Will start training from scratch.", output_folder)
      else:
          os.makedirs(output_folder)
  
      return resume_training
docs: Check if we should resume a broken training run.
  
      :param args: Arguments as returned by argparse.
      :param output_folder: Main output folder for the model.
      :return: Flag signaling if we are resuming training and the directory with
          the training status.