class_docstr: LightGBM model: https://lightgbm.readthedocs.io/en/latest/
  
  Hyperparameter options: https://lightgbm.readthedocs.io/en/latest/Parameters.html
  
  Extra hyperparameter options:
      ag.early_stop : int, specifies the early stopping rounds. Defaults to an adaptive strategy. Recommended to keep default.
class_docstr_tok: ["LightGBM","model",":","https",":","\/\/lightgbm.readthedocs.io\/en\/latest\/","Hyperparameter","options",":","https",":","\/\/lightgbm.readthedocs.io\/en\/latest\/Parameters.html","Extra","hyperparameter","options",":","ag.early_stop",":","int",",","specifies","the","early","stopping","rounds",".","Defaults","to","an","adaptive","strategy",".","Recommended","to","keep","default","."]
code: def generate_datasets(
      self,
      X: DataFrame,
      y: Series,
      params,
      X_val=None,
      y_val=None,
      sample_weight=None,
      sample_weight_val=None,
      save=False,
  ):
      lgb_dataset_params_keys = [
          "two_round"
      ]  # Keys that are specific to lightGBM Dataset object construction.
      data_params = {
          key: params[key]
          for key in lgb_dataset_params_keys
          if key in params
      }.copy()
  
      X = self.preprocess(X, is_train=True)
      if X_val is not None:
          X_val = self.preprocess(X_val)
      # TODO: Try creating multiple Datasets for subsets of features, then combining with Dataset.add_features_from(), this might avoid memory spike
  
      y_og = None
      y_val_og = None
      if self.problem_type == SOFTCLASS:
          y_og = np.array(y)
          y = None
          if X_val is not None:
              y_val_og = np.array(y_val)
              y_val = None
  
      # X, W_train = self.convert_to_weight(X=X)
      dataset_train = construct_dataset(
          x=X,
          y=y,
          location=os.path.join("self.path", "datasets", "train"),
          params=data_params,
          save=save,
          weight=sample_weight,
      )
      # dataset_train = construct_dataset_lowest_memory(X=X, y=y, location=self.path + 'datasets/train', params=data_params)
      if X_val is not None:
          # X_val, W_val = self.convert_to_weight(X=X_val)
          dataset_val = construct_dataset(
              x=X_val,
              y=y_val,
              location=os.path.join(self.path, "datasets", "val"),
              reference=dataset_train,
              params=data_params,
              save=save,
              weight=sample_weight_val,
          )
          # dataset_val = construct_dataset_lowest_memory(X=X_val, y=y_val, location=self.path + 'datasets/val', reference=dataset_train, params=data_params)
      else:
          dataset_val = None
      if self.problem_type == SOFTCLASS:
          if y_og is not None:
              dataset_train.softlabels = y_og
          if y_val_og is not None:
              dataset_val.softlabels = y_val_og
      return dataset_train, dataset_val
  
imports: import gc
  import logging
  import os
  import random
  import re
  import time
  import warnings
  import numpy
  from pandas import DataFrame, Series
  from autogluon.common.features.types import R_BOOL, R_CATEGORY, R_FLOAT, R_INT
  from autogluon.common.utils.pandas_utils import get_approximate_df_mem_usage
  from autogluon.common.utils.resource_utils import ResourceManager
  from autogluon.common.utils.try_import import try_import_lightgbm
  from autogluon.core.constants import BINARY, MULTICLASS, QUANTILE, REGRESSION, SOFTCLASS
  from autogluon.core.models import AbstractModel
  from autogluon.core.models._utils import get_early_stopping_rounds
  from .None import lgb_utils
  from .hyperparameters.parameters import DEFAULT_NUM_BOOST_ROUND, get_lgb_objective, get_param_baseline
  from .hyperparameters.searchspaces import get_default_searchspace
  from .lgb_utils import construct_dataset, train_lgb_model
label_desc: Use image node_id 9 for calling the LGBModel obj's underlying member method code with example usage: obj.generate_datasets(X, y, params, X_val, y_val, sample_weight, sample_weight_val, save) and returns: dataset_train,  dataset_val