code: def fit_logistic_regression_preset_splits(
      X, y, train_mask, val_mask, test_mask
  ):
      # transform targets to one-hot vector
      one_hot_encoder = OneHotEncoder(categories="auto", sparse=False)
      y = one_hot_encoder.fit_transform(y.reshape(-1, 1)).astype(
          np.bool_
      )
  
      # normalize x
      X = normalize(X, norm="l2")
  
      accuracies = []
      for split_id in range(train_mask.shape[1]):
          # get train/val/test masks
          tmp_train_mask, tmp_val_mask = (
              train_mask[:, split_id],
              val_mask[:, split_id],
          )
  
          # make custom cv
          X_train, y_train = X[tmp_train_mask], y[tmp_train_mask]
          X_val, y_val = X[tmp_val_mask], y[tmp_val_mask]
          X_test, y_test = X[test_mask], y[test_mask]
  
          # grid search with one-vs-rest classifiers
          best_test_acc, best_acc = 0, 0
          for c in 2.0 ** np.arange(-10, 11):
              clf = OneVsRestClassifier(
                  LogisticRegression(solver="liblinear", C=c)
              )
              clf.fit(X_train, y_train)
  
              y_pred = clf.predict_proba(X_val)
              y_pred = np.argmax(y_pred, axis=1)
              y_pred = one_hot_encoder.transform(
                  y_pred.reshape(-1, 1)
              ).astype(np.bool_)
              val_acc = metrics.accuracy_score(y_val, y_pred)
              if val_acc > best_acc:
                  best_acc = val_acc
                  y_pred = clf.predict_proba(X_test)
                  y_pred = np.argmax(y_pred, axis=1)
                  y_pred = one_hot_encoder.transform(
                      y_pred.reshape(-1, 1)
                  ).astype(np.bool_)
                  best_test_acc = metrics.accuracy_score(y_test, y_pred)
  
          accuracies.append(best_test_acc)
      return accuracies
  
file_path: dgl/examples/pytorch/bgrl/eval_function.py
imports: import numpy
  import torch
  from sklearn import metrics
  from sklearn.linear_model import LogisticRegression
  from sklearn.model_selection import GridSearchCV, ShuffleSplit, train_test_split
  from sklearn.multiclass import OneVsRestClassifier
  from sklearn.preprocessing import normalize, OneHotEncoder
label_desc: Use image node_id 2 for calling a global function with example usage: fit_logistic_regression_preset_splits(X, y, train_mask, val_mask, test_mask) and returns: accuracies