code: def search_base_learner(id):
      """Creates a set of base learners from base learner origin using grid search
      and queues them up
      """
      path = functions.get_path_from_query_string(request)
      req_body = request.get_json()
      if req_body["method"] == "grid":
          param_grid = functions.import_object_from_string_code(
              req_body["source"], "param_grid"
          )
          iterator = ParameterGrid(param_grid)
      elif req_body["method"] == "random":
          param_distributions = (
              functions.import_object_from_string_code(
                  req_body["source"], "param_distributions"
              )
          )
          iterator = ParameterSampler(
              param_distributions, n_iter=req_body["n_iter"]
          )
  
      else:
          raise exceptions.UserError(
              "{} not a valid search method".format(req_body["method"])
          )
  
      with functions.DBContextManager(path) as session:
          base_learner_origin = (
              session.query(models.BaseLearnerOrigin)
              .filter_by(id=id)
              .first()
          )
          if base_learner_origin is None:
              raise exceptions.UserError(
                  "Base learner origin {} not found".format(id), 404
              )
  
          if not base_learner_origin.final:
              raise exceptions.UserError(
                  "Base learner origin {} is not final".format(id)
              )
  
          learners = []
          for params in iterator:
              est = base_learner_origin.return_estimator()
              try:
                  est.set_params(**params)
              except Exception as e:
                  print(repr(e))
                  continue
  
              hyperparameters = functions.make_serializable(
                  est.get_params()
              )
  
              base_learners = (
                  session.query(models.BaseLearner)
                  .filter_by(
                      base_learner_origin_id=id,
                      hyperparameters=hyperparameters,
                  )
                  .all()
              )
              if base_learners:  # already exists
                  continue
  
              base_learner = models.BaseLearner(
                  hyperparameters, "queued", base_learner_origin
              )
  
              session.add(base_learner)
              session.commit()
              with Connection(get_redis_connection()):
                  rqtasks.generate_meta_features.delay(
                      path, base_learner.id
                  )
              learners.append(base_learner)
  
          if not learners:
              raise exceptions.UserError("Created 0 new base learners")
  
          if req_body["method"] == "grid":
              if "grid_searches" not in base_learner_origin.description:
                  base_learner_origin.description["grid_searches"] = []
              base_learner_origin.description["grid_searches"] += [
                  req_body["source"]
              ]
          elif req_body["method"] == "random":
              if (
                  "random_searches"
                  not in base_learner_origin.description
              ):
                  base_learner_origin.description[
                      "random_searches"
                  ] = []
              base_learner_origin.description["random_searches"] += [
                  req_body["source"]
              ]
  
          session.add(base_learner_origin)
          session.commit()
  
          return jsonify(list(map(lambda x: x.serialize, learners)))
  
imports: from __future__ import absolute_import, print_function, division, unicode_literals
  import os
  from flask import request, jsonify, send_from_directory, g
  from redis import Redis
  from rq import Connection
  from sqlalchemy import create_engine
  from sklearn.model_selection import ParameterGrid
  from sklearn.model_selection import ParameterSampler
  from xcessiv import app, functions, exceptions, models, rqtasks
  from xcessiv.presets import learnersetting, metricsetting, cvsetting
  import six
label_desc: Use image node_id 19 for calling a global function with example usage: search_base_learner(id) and returns: jsonify