code: def gen_data(
      nobs, nvar, const, pandas=False, missing=0.0, weights=False
  ):
      rs = np.random.RandomState(987499302)
      x = rs.standard_normal((nobs, nvar))
      cols = [f"x{i}" for i in range(nvar)]
      if const:
          x = tools.add_constant(x)
          cols = ["const"] + cols
      if missing > 0.0:
          mask = rs.random_sample(x.shape) < missing
          x[mask] = np.nan
      if x.shape[1] > 1:
          y = x[:, :-1].sum(1) + rs.standard_normal(nobs)
      else:
          y = x.sum(1) + rs.standard_normal(nobs)
      w = rs.chisquare(5, y.shape[0]) / 5
      if pandas:
          idx = pd.date_range("12-31-1999", periods=nobs)
          x = pd.DataFrame(x, index=idx, columns=cols)
          y = pd.Series(y, index=idx, name="y")
          w = pd.Series(w, index=idx, name="weights")
      if not weights:
          w = None
  
      return y, x, w
  
imports: from io import BytesIO
  from itertools import product
  import warnings
  import numpy
  import pandas
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal
  from statsmodels import tools
  from statsmodels.regression.linear_model import WLS
  from statsmodels.regression.rolling import RollingWLS, RollingOLS
label_desc: Use image node_id 1 for calling a global function with example usage: gen_data(nobs, nvar, const, pandas, missing, weights) and returns: y,  x,  w