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","."]
docstr: Returns the expected peak memory usage in bytes of the LightGBM model during fit.
  
  The memory usage of LightGBM is primarily made up of two sources:
  
  1. The size of the data
  2. The size of the histogram cache
      Scales roughly by 5100*num_features*num_leaves bytes
      For 10000 features and 128 num_leaves, the histogram would be 6.5 GB.
docstr_tok: ["Returns","the","expected","peak","memory","usage","in","bytes","of","the","LightGBM","model","during","fit",".","The","memory","usage","of","LightGBM","is","primarily","made","up","of","two","sources",":","1",".","The","size","of","the","data","2",".","The","size","of","the","histogram","cache","Scales","roughly","by","5100","*","num_features","*","num_leaves","bytes","For","10000","features","and","128","num_leaves",",","the","histogram","would","be","6.5","GB","."]
code: def _estimate_memory_usage(self, X: DataFrame, **kwargs) -> float:
      """
      Returns the expected peak memory usage in bytes of the LightGBM model during fit.
  
      The memory usage of LightGBM is primarily made up of two sources:
  
      1. The size of the data
      2. The size of the histogram cache
          Scales roughly by 5100*num_features*num_leaves bytes
          For 10000 features and 128 num_leaves, the histogram would be 6.5 GB.
      """
      num_classes = (
          self.num_classes if self.num_classes else 1
      )  # self.num_classes could be None after initialization if it's a regression problem
      data_mem_usage = get_approximate_df_mem_usage(X).sum()
      data_mem_usage_bytes = (
          data_mem_usage * 5 + data_mem_usage / 4 * num_classes
      )  # TODO: Extremely crude approximation, can be vastly improved
  
      params = self._get_model_params()
      max_bins = params.get("max_bins", 255)
      num_leaves = params.get("num_leaves", 31)
      # Memory usage of histogram based on https://github.com/microsoft/LightGBM/issues/562#issuecomment-304524592
      histogram_mem_usage_bytes = (
          20 * max_bins * len(X.columns) * num_leaves
      )
      histogram_mem_usage_bytes_max = params.get(
          "histogram_pool_size", None
      )
      if histogram_mem_usage_bytes_max is not None:
          histogram_mem_usage_bytes_max *= 1e6  # Convert megabytes to bytes, `histogram_pool_size` is in MB.
          if histogram_mem_usage_bytes > histogram_mem_usage_bytes_max:
              histogram_mem_usage_bytes = histogram_mem_usage_bytes_max
      histogram_mem_usage_bytes *= 1.2  # Add a 20% buffer
  
      approx_mem_size_req = (
          data_mem_usage_bytes + histogram_mem_usage_bytes
      )
      return approx_mem_size_req
  
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 5 for calling the LGBModel obj's underlying member method code with example usage: obj._estimate_memory_usage(X) and returns: approx_mem_size_req