class_docstr: SVM trainer that takes care of training (using k-fold cross validation),
  and evaluating the SVMs
class_docstr_tok: ["SVM","trainer","that","takes","care","of","training","(","using","k-fold","cross","validation",")",",","and","evaluating","the","SVMs"]
docstr: During the SVM training, we write the cross validation
  AP value for training at each class and cost value
  combination. We load the AP values and for each
  class, determine the cost value that gives the maximum
  AP. We return the chosen cost values for each class as a
  numpy matrix.
docstr_tok: ["During","the","SVM","training",",","we","write","the","cross","validation","AP","value","for","training","at","each","class","and","cost","value","combination",".","We","load","the","AP","values","and","for","each","class",",","determine","the","cost","value","that","gives","the","maximum","AP",".","We","return","the","chosen","cost","values","for","each","class","as","a","numpy","matrix","."]
code: def get_best_cost_value(self):
      """
      During the SVM training, we write the cross validation
      AP value for training at each class and cost value
      combination. We load the AP values and for each
      class, determine the cost value that gives the maximum
      AP. We return the chosen cost values for each class as a
      numpy matrix.
      """
      crossval_ap_file = f"{self.output_dir}/crossval_ap.npy"
      chosen_cost_file = f"{self.output_dir}/chosen_cost.npy"
      if g_pathmgr.exists(crossval_ap_file) and g_pathmgr.exists(
          chosen_cost_file
      ):
          self.chosen_cost = load_file(chosen_cost_file)
          self.train_ap_matrix = load_file(crossval_ap_file)
          return self.chosen_cost
      if self.train_ap_matrix is None:
          num_classes = len(self.cls_list)
          self.train_ap_matrix = np.zeros(
              (num_classes, len(self.costs_list))
          )
          for cls_num in range(num_classes):
              for cost_idx in range(len(self.costs_list)):
                  cost = self.costs_list[cost_idx]
                  _, ap_out_file = self._get_svm_model_filename(
                      cls_num, cost
                  )
                  self.train_ap_matrix[cls_num][cost_idx] = float(
                      load_file(ap_out_file)[0]
                  )
      argmax_cls = np.argmax(self.train_ap_matrix, axis=1)
      chosen_cost = [self.costs_list[idx] for idx in argmax_cls]
      logging.info(f"chosen_cost: {chosen_cost}")
      save_file(np.array(self.train_ap_matrix), crossval_ap_file)
      save_file(np.array(chosen_cost), chosen_cost_file)
      logging.info(f"saved crossval_ap AP to file: {crossval_ap_file}")
      logging.info(f"saved chosen costs to file: {chosen_cost_file}")
      self.chosen_cost = chosen_cost
      return np.array(chosen_cost)
  
imports: import logging
  import pickle
  import threading
  import numpy
  from iopath.common.file_io import g_pathmgr
  from sklearn.model_selection import cross_val_score
  from sklearn.svm import LinearSVC
  from vissl.utils.io import load_file, save_file
  from vissl.utils.svm_utils.evaluate import get_precision_recall
label_desc: Use image node_id 8 for calling the SVMTrainer obj's underlying member method code with example usage: obj.get_best_cost_value() and returns: np, self