code: def gen_data(
      dataset_name,
      dataset_format,
      n_samples=0,
      n_features=0,
      test_fraction=0.0,
      datasets_root_dir=DATASETS_DIRECTORY,
      dtype=np.float32,
      **kwargs,
  ):
      """Returns a tuple of data from the specified generator.
  
      Parameters
      ----------
      dataset_name : str
          Dataset to use. Can be a synthetic generator (blobs or regression)
          or a specified dataset (higgs currently, others coming soon)
      dataset_format : str
          Type of data to return. (One of cudf, numpy, pandas, gpuarray)
      n_samples : int
          Total number of samples to loaded including training and testing samples
      test_fraction : float
          Fraction of the dataset to partition randomly into the test set.
          If this is 0.0, no test set will be created.
  
      Returns
      -------
          (train_features, train_labels, test_features, test_labels) tuple
          containing matrices or dataframes of the requested format.
          test_features and test_labels may be None if no splitting was done.
      """
  
      pickle_x_file_url = os.path.join(
          datasets_root_dir, "%s_x.pkl" % dataset_name
      )
      pickle_y_file_url = os.path.join(
          datasets_root_dir, "%s_y.pkl" % dataset_name
      )
  
      mock_datasets = ["regression", "classification", "blobs", "zero"]
      if dataset_name in mock_datasets:
          X_df, y_df = _data_generators[dataset_name](
              n_samples=n_samples,
              n_features=n_features,
              dtype=dtype,
              **kwargs,
          )
      else:
          if os.path.isfile(pickle_x_file_url):
              # loading data from cache
              X = pd.read_pickle(pickle_x_file_url)
              y = pd.read_pickle(pickle_y_file_url)
          else:
              X, y = _data_generators[dataset_name](
                  datasets_root_dir, **kwargs
              )
  
              # cache the dataset for future use
              X.to_pickle(pickle_x_file_url)
              y.to_pickle(pickle_y_file_url)
  
          if n_samples > X.shape[0]:
              raise ValueError(
                  "%s dataset has only %d rows, cannot support %d"
                  % (dataset_name, X.shape[0], n_samples)
              )
  
          if n_features > X.shape[1]:
              raise ValueError(
                  "%s dataset has only %d features, cannot support %d"
                  % (dataset_name, X.shape[1], n_features)
              )
  
          if n_samples == 0:
              n_samples = X.shape[0]
  
          if n_features == 0:
              n_features = X.shape[1]
  
          X_df = cudf.DataFrame.from_pandas(
              X.iloc[0:n_samples, 0:n_features].astype(dtype)
          )
          y_df = cudf.Series.from_pandas(
              y.iloc[0:n_samples].astype(dtype)
          )
  
      data = (X_df, y_df)
      if test_fraction != 0.0:
          random_state_dict = (
              {"random_state": kwargs["random_state"]}
              if "random_state" in kwargs
              else {}
          )
          X_train, X_test, y_train, y_test = tuple(
              sklearn.model_selection.train_test_split(
                  *data,
                  test_size=int(n_samples * test_fraction),
                  **random_state_dict,
              )
          )
          data = (X_train, y_train, X_test, y_test)
      else:
          data = (*data, None, None)  # No test set
      data = _data_converters[dataset_format](data)
      return data
  
imports: from cuml.internals.import_utils import has_scipy
  from cuml.internals.safe_imports import gpu_only_import_from
  from cuml.internals import input_utils
  from urllib.request import urlretrieve
  import sklearn.model_selection
  from sklearn.datasets import load_svmlight_file, fetch_covtype
  import cuml.datasets
  from cuml.internals.safe_imports import cpu_only_import
  import os
  import functools
  import gzip
  from cuml.internals.safe_imports import gpu_only_import
label_desc: Use image node_id 24 for calling a global function with example usage: gen_data(dataset_name, dataset_format, n_samples, n_features, test_fraction, datasets_root_dir, dtype) and returns: data