def METHOD_NAME(argparser, argv, log_dir):
    args = argparser.parse_args(args=argv)
    if isinstance(argparser, CustomArgumentParser):
        cli_args = {k: v for k, v in vars(args).items() if k in argparser.seen_actions}
    else:
        cli_args = {k: v for k, v in vars(args).items() if v is not None}
    with open(osp.join(log_dir, "cli_args.json"), "w", encoding="utf8") as f:
        json.dump(cli_args, f, indent=4)