def METHOD_NAME():
    args = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
    try:
        import bpy
    except ImportError:
        # Run outside of Blender, just show "--help".
        bpy = None
        args.insert(0, "--help")
    args = argparse_create().parse_args(args)
    if bpy is None:
        return
    from bpy import context
    preset = args.preset
    output_dir = args.output_dir
    os.makedirs(output_dir, exist_ok=True)
    # Needed for background mode.
    preset_filepath = bpy.utils.preset_find(preset, preset_path="keyconfig")
    bpy.ops.preferences.keyconfig_activate(filepath=preset_filepath)
    # Key-map preferences..
    km_prefs = context.window_manager.keyconfigs.active.preferences
    config = []
    # Use RNA introspection:
    if args.keymap_prefs:
        for attr in args.keymap_prefs.split(":"):
            if not hasattr(km_prefs, attr):
                print(f"KeyMap preferences does not have attribute: {attr:s}")
                sys.exit(1)
            prop_def = km_prefs.rna_type.properties.get(attr)
            match prop_def.type:
                case 'ENUM':
                    value = tuple(val.identifier for val in prop_def.enum_items)
                case 'BOOLEAN':
                    value = (True, False)
                case _ as prop_def_type:
                    raise Exception(f"Unhandled attribute type {prop_def_type:s}")
            config.append((attr, value))
    config = tuple(config)
    for attr_permutation in (permutations_from_attrs(config) or ((),)):
        # Reload and set.
        if attr_permutation is not None:
            km_prefs = context.window_manager.keyconfigs.active.preferences
            for attr, value in attr_permutation:
                setattr(km_prefs, attr, value)
        # Re-activate after setting preferences, tsk, ideally this shouldn't be necessary.
        bpy.ops.preferences.keyconfig_activate(filepath=preset_filepath)
        filepath = os.path.join(output_dir, permutation_as_filename(preset, attr_permutation) + ".py")
        print("Writing:", filepath)
        bpy.ops.preferences.keyconfig_export(filepath=filepath, all=True)
    sys.exit()