code: def write_formula_api(directory):
      template_classes = [
          "DiscreteModel",
          "BinaryModel",
          "MultinomialModel",
          "OrderedModel",
          "CountModel",
          "LikelihoodModel",
          "GenericLikelihoodModel",
          "TimeSeriesModel",
          # this class should really be deleted
          "ARIMAProcess",
          # these need some more work, so do not expose them
          "ARIMA",
          "VAR",
          "SVAR",
          "AR",
          "NBin",
          "NbReg",
          "ARMA",
      ]
  
      path = os.path.join(directory, "statsmodels", "formula", "api.py")
      fout = open(path, "w", encoding="utf-8")
      for model in iter_subclasses(
          Model, template_classes=template_classes
      ):
          print("Generating API for %s" % model.__name__)
          fout.write(
              "from "
              + model.__module__
              + " import "
              + model.__name__
              + "\n"
          )
          fout.write(
              model.__name__.lower()
              + " = "
              + model.__name__
              + ".from_formula\n"
          )
      fout.close()
  
imports: import os
  import sys
label_desc: Use image node_id 2 for calling a global function with example usage: write_formula_api(directory) without return types