def load_model(args, num_labels):
    logger.info('Loading pretrained model and tokenizer')
    config = AutoConfig.from_pretrained((args.config_name if args.config_name else args.model_name_or_path), num_labels=num_labels, cache_dir=args.cache_dir)
    args.model_type = config.model_type
    tokenizer = AutoTokenizer.from_pretrained((args.tokenizer_name if args.tokenizer_name else args.model_name_or_path), do_lower_case=args.do_lower_case, cache_dir=args.cache_dir, use_fast=False)
    if args.init_checkpoint:
        logger.info('loading from init_checkpoint={}'.format(args.init_checkpoint))
        model = AutoModelForTokenClassification.from_pretrained(args.init_checkpoint, config=config, cache_dir=args.cache_dir)
    else:
        logger.info('loading from existing model {}'.format(args.model_name_or_path))
        model = AutoModelForTokenClassification.from_pretrained(args.model_name_or_path, from_tf=bool(('.ckpt' in args.model_name_or_path)), config=config, cache_dir=args.cache_dir)
    lang2id = (config.lang2id if (args.model_type == 'xlm') else None)
    logger.info('Using lang2id = {}'.format(lang2id))
    return (model, tokenizer, lang2id)
def load_model(args, num_labels):
    logger.info('Loading pretrained model and tokenizer')
    config = AutoConfig.from_pretrained((args.config_name if args.config_name else args.model_name_or_path), num_labels=num_labels, cache_dir=args.cache_dir)
    args.model_type = config.model_type
    tokenizer = AutoTokenizer.from_pretrained((args.tokenizer_name if args.tokenizer_name else args.model_name_or_path), do_lower_case=args.do_lower_case, cache_dir=args.cache_dir, use_fast=False)
    if args.init_checkpoint:
        logger.info('loading from init_checkpoint={}'.format(args.init_checkpoint))
        model = AutoModelForTokenClassification.from_pretrained(args.init_checkpoint, config=config, cache_dir=args.cache_dir)
    else:
        logger.info('loading from existing model {}'.format(args.model_name_or_path))
        model = AutoModelForTokenClassification.from_pretrained(args.model_name_or_path, from_tf=bool(('.ckpt' in args.model_name_or_path)), config=config, cache_dir=args.cache_dir)
    lang2id = (config.lang2id if (args.model_type == 'xlm') else None)
    logger.info('Using lang2id = {}'.format(lang2id))
    return (model, tokenizer, lang2id)