code: def objective(trial):
      iris = load_iris()
      classes = np.unique(iris.target)
      X_train, X_valid, y_train, y_valid = train_test_split(
          iris.data,
          iris.target,
          train_size=100,
          test_size=50,
          random_state=0,
      )
  
      loss = trial.suggest_categorical(
          "loss", ["hinge", "log_loss", "perceptron"]
      )
      alpha = trial.suggest_float("alpha", 0.00001, 0.001, log=True)
      clf = SGDClassifier(loss=loss, alpha=alpha, random_state=0)
      score = 0
  
      for step in range(0, 5):
          clf.partial_fit(X_train, y_train, classes=classes)
          score = clf.score(X_valid, y_valid)
  
          trial.report(score, step)
  
          if trial.should_prune():
              raise optuna.TrialPruned()
  
      return score
  
file_path: optuna/tutorial/20_recipes/006_user_defined_pruner.py
imports: import numpy
  from sklearn.datasets import load_iris
  from sklearn.model_selection import train_test_split
  from sklearn.linear_model import SGDClassifier
  import optuna
  from optuna.pruners import BasePruner
  from optuna.trial._state import TrialState
label_desc: Use image node_id 1 for calling a global function with example usage: objective(trial) and returns: score