code: def statsmodels_baseline(
      genotype_df,
      phenotype_df,
      covariate_df,
      offset_dfs=None,
      add_intercept=True,
  ):
      if add_intercept:
          covariate_df = sm.add_constant(covariate_df)
      p_values = []
      chisq = []
      for phenotype in phenotype_df:
          for genotype_idx in range(genotype_df.shape[1]):
              mask = ~np.isnan(phenotype_df[phenotype].to_numpy())
              if offset_dfs is not None:
                  offset = offset_dfs[genotype_idx][phenotype]
              else:
                  offset = None
              model = sm.GLM(
                  phenotype_df[phenotype],
                  covariate_df,
                  offset=offset,
                  family=sm.families.Binomial(),
                  missing="drop",
              )
              params = model.fit().params
              results = model.score_test(
                  params,
                  exog_extra=genotype_df.iloc[:, genotype_idx].array[
                      mask
                  ],
              )
              chisq.append(results[0])
              p_values.append(results[1])
      return pd.DataFrame(
          {
              "chisq": np.concatenate(chisq),
              "pvalue": np.concatenate(p_values),
              "phenotype": phenotype_df.columns.to_series()
              .astype("str")
              .repeat(genotype_df.shape[1]),
          }
      )
  
imports: from pyspark.sql.types import ArrayType, DoubleType
  import glow.gwas.log_reg
  import glow.gwas.functions
  import statsmodels.api
  import pandas
  import numpy
  import pytest
label_desc: Use image node_id 2 for calling a global function with example usage: statsmodels_baseline(genotype_df, phenotype_df, covariate_df, offset_dfs, add_intercept) and returns: pd