class_docstr: Train a XGBoost model to predict the normalized throughputs of programs.
  Let the normalized throughput be the score of a program (higher is better). We predict
  the (approximate) score of a program = the sum of the scores of all stages in this program.
  i.e. score(P) = score_s0 + score_s1 + ... + score_sn,
  where score_si is the score of Stage i in Program P.
  We extract feature for each stage and let the xgboost predict the score for each stage.
  We then sum up the predictions as the score of the whole program.
  We use RMSE as the loss function.  i.e. loss(P, y) = 1/2 * (score(P) - y)^2,
  where P is the program and y is the normalized throughput according to
  the ground truth (measurement).
  XGBoost does not support this loss function because `score(P)` is a sum of the prediction
  of several samples, so we implemented a custom loss function and call it pack-sum-rmse.
  It is called "pack-sum" because we combine several samples into a "pack" and sum up
  their predictions.
  
  Parameters
  ----------
  verbose_eval: int = 25
      Print training log every `verbose_eval` iterations.
  num_warmup_sample: int = 100
      The minimum number of samples to start to use the trained model.
      If the number of samples is less than this number, the model outputs random predictions.
  seed: Optional[int]
      The random seed
  model_file: Optional[str]
      If is not None, save model to this file after every update.
  adaptive_training: bool = False
      Whether to use adaptive training, which reduces the training frequency when there are
      too many logs.
class_docstr_tok: ["Train","a","XGBoost","model","to","predict","the","normalized","throughputs","of","programs",".","Let","the","normalized","throughput","be","the","score","of","a","program","(","higher","is","better",")",".","We","predict","the","(","approximate",")","score","of","a","program","=","the","sum","of","the","scores","of","all","stages","in","this","program",".","i.e",".","score","(","P",")","=","score_s0","+","score_s1","+","...","+","score_sn",",","where","score_si","is","the","score","of","Stage","i","in","Program","P.","We","extract","feature","for","each","stage","and","let","the","xgboost","predict","the","score","for","each","stage",".","We","then","sum","up","the","predictions","as","the","score","of","the","whole","program",".","We","use","RMSE","as","the","loss","function",".","i.e",".","loss","(","P",",","y",")","=","1\/2","*","(","score","(","P",")","-","y",")","^2",",","where","P","is","the","program","and","y","is","the","normalized","throughput","according","to","the","ground","truth","(","measurement",")",".","XGBoost","does","not","support","this","loss","function","because","`","score","(","P",")","`","is","a","sum","of","the","prediction","of","several","samples",",","so","we","implemented","a","custom","loss","function","and","call","it","pack-sum-rmse",".","It","is","called","``","pack-sum","''","because","we","combine","several","samples","into","a","``","pack","''","and","sum","up","their","predictions",".","Parameters","--","--","--","--","--","verbose_eval",":","int","=","25","Print","training","log","every","`","verbose_eval","`","iterations",".","num_warmup_sample",":","int","=","100","The","minimum","number","of","samples","to","start","to","use","the","trained","model",".","If","the","number","of","samples","is","less","than","this","number",",","the","model","outputs","random","predictions",".","seed",":","Optional","[","int","]","The","random","seed","model_file",":","Optional","[","str","]","If","is","not","None",",","save","model","to","this","file","after","every","update",".","adaptive_training",":","bool","=","False","Whether","to","use","adaptive","training",",","which","reduces","the","training","frequency","when","there","are","too","many","logs","."]
docstr: Save the model to a file
  Parameters
  ----------
  file_name: str
      The filename
docstr_tok: ["Save","the","model","to","a","file","Parameters","--","--","--","--","--","file_name",":","str","The","filename"]
code: def save(self, file_name: str):
      """Save the model to a file
      Parameters
      ----------
      file_name: str
          The filename
      """
      self.bst.save_model(file_name)
  
imports: import multiprocessing
  import logging
  from typing import Dict
  from collections import defaultdict
  import numpy
  from tvm.autotvm.tuner.metric import max_curve
  from .cost_model import PythonBasedModel
  from ..feature import get_per_store_features_from_measure_pairs, get_per_store_features_from_states
  from ..measure_record import RecordReader
label_desc: Use image node_id 6 for calling the XGBModel obj's underlying member method code with example usage: obj.save(file_name) without return types