code: def create_model(
      model_type, n_samples, n_features, with_intercept=True
  ):
      weights = np.random.randn(n_features)
      intercept = None
      if with_intercept:
          intercept = np.random.normal()
  
      if model_type == "Poisson":
          # we need to rescale features to avoid overflows
          weights /= n_features
          if intercept is not None:
              intercept /= n_features
  
      if model_type == "Linear":
          simulator = SimuLinReg(
              weights,
              intercept=intercept,
              n_samples=n_samples,
              verbose=False,
          )
      elif model_type == "Logistic":
          simulator = SimuLogReg(
              weights,
              intercept=intercept,
              n_samples=n_samples,
              verbose=False,
          )
      elif model_type == "Poisson":
          simulator = SimuPoisReg(
              weights,
              intercept=intercept,
              n_samples=n_samples,
              verbose=False,
          )
  
      labels, features = simulator.simulate()
  
      if model_type == "Linear":
          model = ModelLinReg(fit_intercept=with_intercept)
      elif model_type == "Logistic":
          model = ModelLogReg(fit_intercept=with_intercept)
      elif model_type == "Poisson":
          model = ModelPoisReg(fit_intercept=with_intercept)
  
      model.fit(labels, features)
      return model
  
file_path: tick/examples/plot_glm_convergence.py
imports: import matplotlib.pyplot
  from tick.plot import plot_history
  import numpy
  from itertools import product
  from tick.linear_model import SimuLinReg, SimuLogReg, SimuPoisReg, ModelLinReg, ModelLogReg, ModelPoisReg
  from tick.solver import SDCA, SVRG, BFGS, GD, AGD
  from tick.prox import ProxZero, ProxL2Sq
label_desc: Use image node_id 1 for calling a global function with example usage: create_model(model_type, n_samples, n_features, with_intercept) and returns: model