def METHOD_NAME(state_dir: Path, file: Path = None, reset_config_on_error: bool = False) -> TriblerConfig:
    """ Load a config from a file
    Args:
        state_dir: A Tribler's state dir.
        file: A path to the config file.
        reset_config_on_error: a flag that shows whether it is necessary to
            create a new config in case of an error.
    Returns: `TriblerConfig` instance.
    """
    file = file or state_dir / DEFAULT_CONFIG_NAME
    logger.info(f'Load: {file}. State dir: {state_dir}. Reset config on error: {reset_config_on_error}')
    error = None
    config = None
    try:
        dictionary = configobj.ConfigObj(infile=str(file))
        config = TriblerConfig.parse_obj(dictionary)
        config.set_state_dir(state_dir)
        config.set_file(file)
    except (ParseError, ValueError) as e:
        logger.error(e)
        if not reset_config_on_error:
            raise
        error = traceback.format_exc()
    if error:
        logger.info('Resetting a config')
        config = TriblerConfig(state_dir=state_dir, file=file, error=error)
        config.write(file=file)
    return config