def METHOD_NAME():
    training_args, model_args = PdArgumentParser([TrainingArguments, ModelArguments]).parse_args_into_dataclasses()
    training_args: TrainingArguments = training_args
    model_args: ModelArguments = model_args
    paddle.set_device(training_args.device)
    if paddle.distributed.get_world_size() > 1:
        paddle.distributed.init_parallel_env()
    set_seed(training_args.seed)
    model_args.task_name = model_args.task_name.lower()
    metric_class = METRIC_CLASSES[model_args.task_name]
    def compute_metrics(p):
        preds = p.predictions[0] if isinstance(p.predictions, tuple) else p.predictions
        preds = paddle.to_tensor(preds)
        label = paddle.to_tensor(p.label_ids)
        metric = metric_class()
        result = metric.compute(preds, label)
        metric.update(result)
        if isinstance(metric, AccuracyAndF1):
            acc, precision, recall, f1, _ = metric.accumulate()
            return {"accuracy": acc, "precision": precision, "recall": recall, "f1": f1}
        elif isinstance(metric, Mcc):
            mcc = metric.accumulate()
            return {"mcc": mcc[0]}
        elif isinstance(metric, PearsonAndSpearman):
            pearson, spearman, _ = metric.accumulate()
            return {"pearson": pearson, "spearman": spearman}
    train_ds = load_dataset("glue", model_args.task_name, splits="train")
    tokenizer = GPTTokenizer.from_pretrained(model_args.model_name_or_path)
    trans_func = partial(
        convert_example, tokenizer=tokenizer, label_list=train_ds.label_list, max_seq_length=model_args.max_seq_length
    )
    train_ds = train_ds.map(trans_func, lazy=True)
    train_batch_sampler = paddle.io.DistributedBatchSampler(
        train_ds, batch_size=training_args.train_batch_size, shuffle=True
    )
    train_data_loader = DataLoader(
        dataset=train_ds, batch_sampler=train_batch_sampler, num_workers=0, return_list=True
    )
    if model_args.task_name == "mnli":
        dev_ds = load_dataset("glue", model_args.task_name, splits=["dev_matched"])
    else:
        dev_ds = load_dataset("glue", model_args.task_name, splits="dev")
    dev_ds = dev_ds.map(trans_func, lazy=True)
    num_classes = 1 if train_ds.label_list is None else len(train_ds.label_list)
    model = GPTForSequenceClassification.from_pretrained(model_args.model_name_or_path, num_labels=num_classes)
    if paddle.distributed.get_world_size() > 1:
        model = paddle.DataParallel(model)
    num_training_steps = (
        training_args.max_steps
        if training_args.max_steps > 0
        else (len(train_data_loader) * training_args.num_train_epochs)
    )
    warmup = training_args.warmup_steps if training_args.warmup_steps > 0 else training_args.warmup_ratio
    lr_scheduler = LinearDecayWithWarmup(training_args.learning_rate, num_training_steps, warmup)
    # Generate parameter names needed to perform weight decay.
    # All bias and LayerNorm parameters are excluded.
    decay_params = [p.name for n, p in model.named_parameters() if not any(nd in n for nd in ["bias", "norm"])]
    optimizer = paddle.optimizer.AdamW(
        learning_rate=lr_scheduler,
        beta1=0.9,
        beta2=0.999,
        epsilon=training_args.adam_epsilon,
        parameters=model.parameters(),
        weight_decay=training_args.weight_decay,
        apply_decay_param_fun=lambda x: x in decay_params,
    )
    loss_fct = paddle.nn.loss.CrossEntropyLoss() if train_ds.label_list else paddle.nn.loss.MSELoss()
    # TODO(wj-Mcat): use amp
    trainer = Trainer(
        model=model,
        args=training_args,
        data_collator=DataCollatorWithPadding(tokenizer=tokenizer, padding=True, max_length=model_args.max_seq_length),
        criterion=loss_fct,
        train_dataset=train_ds,
        eval_dataset=dev_ds,
        tokenizer=tokenizer,
        compute_metrics=compute_metrics,
        optimizers=[optimizer, lr_scheduler],
    )
    if training_args.METHOD_NAME:
        train_result = trainer.train()
        metrics = train_result.metrics
        trainer.save_model()
        trainer.log_metrics("train", metrics)
        trainer.save_state()