code: def run_demo(
      mode,
      base_alpha=0.01,
      N=500,
      get_l1_slsqp_results=False,
      get_l1_cvxopt_results=False,
      num_nonconst_covariates=10,
      noise_level=0.2,
      cor_length=2,
      num_zero_params=8,
      num_targets=3,
      print_summaries=False,
      save_arrays=False,
      load_old_arrays=False,
  ):
      """
      Run the demo and print results.
  
      Parameters
      ----------
      mode : str
          either 'logit', 'mnlogit', or 'probit'
      base_alpha :  Float
          Size of regularization param (the param actually used will
          automatically scale with data size in this demo)
      N : int
          Number of data points to generate for fit
      get_l1_slsqp_results : bool,
          Do an l1 fit using slsqp.
      get_l1_cvxopt_results : bool
          Do an l1 fit using cvxopt
      num_nonconst_covariates : int
          Number of covariates that are not constant
          (a constant will be prepended)
      noise_level : float (non-negative)
          Level of the noise relative to signal
      cor_length : float (non-negative)
          Correlation length of the (Gaussian) independent variables
      num_zero_params : int
          Number of parameters equal to zero for every target in logistic
          regression examples.
      num_targets : int
          Number of choices for the endogenous response in multinomial logit
          example
      print_summaries : bool
          print the full fit summary.
      save_arrays : bool
          Save exog/endog/true_params to disk for future use.
      load_old_arrays
          Load exog/endog/true_params arrays from disk.
      """
      if mode != "mnlogit":
          print("Setting num_targets to 2 since mode != 'mnlogit'")
          num_targets = 2
      models = {
          "logit": sm.Logit,
          "mnlogit": sm.MNLogit,
          "probit": sm.Probit,
      }
      endog_funcs = {
          "logit": get_logit_endog,
          "mnlogit": get_logit_endog,
          "probit": get_probit_endog,
      }
      # The regularization parameter
      # Here we scale it with N for simplicity.  In practice, you should
      # use cross validation to pick alpha
      alpha = (
          base_alpha
          * N
          * sp.ones((num_nonconst_covariates + 1, num_targets - 1))
      )
      alpha[0, :] = 0  # Do not regularize the intercept
  
      #### Make the data and model
      exog = get_exog(N, num_nonconst_covariates, cor_length)
      exog = sm.add_constant(exog)
      true_params = sp.rand(
          num_nonconst_covariates + 1, num_targets - 1
      )
      if num_zero_params:
          true_params[-num_zero_params:, :] = 0
      endog = endog_funcs[mode](true_params, exog, noise_level)
  
      endog, exog, true_params = save_andor_load_arrays(
          endog, exog, true_params, save_arrays, load_old_arrays
      )
      model = models[mode](endog, exog)
  
      #### Get the results and print
      results = run_solvers(
          model,
          true_params,
          alpha,
          get_l1_slsqp_results,
          get_l1_cvxopt_results,
          print_summaries,
      )
  
      summary_str = get_summary_str(
          results,
          true_params,
          get_l1_slsqp_results,
          get_l1_cvxopt_results,
          print_summaries,
      )
  
      print(summary_str)
  
file_path: statsmodels/statsmodels/examples/l1_demo/demo.py
imports: from optparse import OptionParser
  import statsmodels.api
  import scipy
  from scipy import linalg
  from scipy import stats
label_desc: Use image node_id 2 for calling a global function with example usage: run_demo(mode, base_alpha, N, get_l1_slsqp_results, get_l1_cvxopt_results, num_nonconst_covariates, noise_level, cor_length, num_zero_params, num_targets, print_summaries, save_arrays, load_old_arrays) without return types