class_docstr: PyTorch neural network models for classification/regression with tabular data.
class_docstr_tok: ["PyTorch","neural","network","models","for","classification\/regression","with","tabular","data","."]
code: def _fit(
      self,
      X,
      y,
      X_val=None,
      y_val=None,
      time_limit=None,
      sample_weight=None,
      num_cpus=1,
      num_gpus=0,
      reporter=None,
      verbosity=2,
      **kwargs,
  ):
      try_import_torch()
      import torch
  
      torch.set_num_threads(num_cpus)
      from .tabular_torch_dataset import TabularTorchDataset
  
      start_time = time.time()
  
      params = self._get_model_params()
  
      (
          processor_kwargs,
          optimizer_kwargs,
          fit_kwargs,
          loss_kwargs,
          params,
      ) = self._prepare_params(params=params)
  
      seed_value = params.pop("seed_value", 0)
  
      self._num_cpus_infer = params.pop("_num_cpus_infer", 1)
      if seed_value is not None:  # Set seeds
          random.seed(seed_value)
          np.random.seed(seed_value)
          torch.manual_seed(seed_value)
  
      if sample_weight is not None:  # TODO: support
          logger.log(
              15,
              f"sample_weight not yet supported for {self.__class__.__name__},"
              " this model will ignore them in training.",
          )
  
      if num_cpus is not None:
          self.num_dataloading_workers = max(1, int(num_cpus / 2.0))
      else:
          self.num_dataloading_workers = 1
      if self.num_dataloading_workers == 1:
          self.num_dataloading_workers = 0  # TODO: verify 0 is typically faster and uses less memory than 1 in pytorch
      self.num_dataloading_workers = 0  # TODO: >0 crashes on MacOS
      self.max_batch_size = params.pop("max_batch_size", 512)
      batch_size = params.pop("batch_size", None)
      if batch_size is None:
          if isinstance(X, TabularTorchDataset):
              batch_size = min(
                  int(2 ** (3 + np.floor(np.log10(len(X))))),
                  self.max_batch_size,
              )
          else:
              batch_size = min(
                  int(2 ** (3 + np.floor(np.log10(X.shape[0])))),
                  self.max_batch_size,
              )
  
      train_dataset, val_dataset = self._generate_datasets(
          X=X, y=y, params=processor_kwargs, X_val=X_val, y_val=y_val
      )
      logger.log(
          15,
          f"Training data for {self.__class__.__name__} has: "
          f"{train_dataset.num_examples} examples, {train_dataset.num_features} features "
          f"({len(train_dataset.feature_groups['vector'])} vector, {len(train_dataset.feature_groups['embed'])} embedding)",
      )
  
      self.device = self._get_device(num_gpus=num_gpus)
  
      self._get_net(train_dataset, params=params)
      self.optimizer = self._init_optimizer(**optimizer_kwargs)
  
      if time_limit is not None:
          time_elapsed = time.time() - start_time
          time_limit_orig = time_limit
          time_limit = time_limit - time_elapsed
  
          # if 60% of time was spent preprocessing, likely not enough time to train model
          if time_limit <= time_limit_orig * 0.4:
              raise TimeLimitExceeded
  
      # train network
      self._train_net(
          train_dataset=train_dataset,
          loss_kwargs=loss_kwargs,
          batch_size=batch_size,
          val_dataset=val_dataset,
          time_limit=time_limit,
          reporter=reporter,
          verbosity=verbosity,
          **fit_kwargs,
      )
  
imports: import json
  import logging
  import os
  import random
  import time
  import warnings
  from typing import Dict, Union
  import numpy
  import pandas
  from autogluon.common.features.types import R_BOOL, R_CATEGORY, R_FLOAT, R_INT, S_TEXT_AS_CATEGORY, S_TEXT_NGRAM
  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_torch
  from autogluon.core.constants import BINARY, MULTICLASS, QUANTILE, REGRESSION, SOFTCLASS
  from autogluon.core.hpo.constants import RAY_BACKEND
  from autogluon.core.models.abstract.abstract_nn_model import AbstractNeuralNetworkModel
  from autogluon.core.utils.exceptions import TimeLimitExceeded
  from ..compilers.native import TabularNeuralNetTorchNativeCompiler
  from ..compilers.onnx import TabularNeuralNetTorchOnnxCompiler
  from ..hyperparameters.parameters import get_default_param
  from ..hyperparameters.searchspaces import get_default_searchspace
  from ..utils.data_preprocessor import create_preprocessor, get_feature_arraycol_map, get_feature_type_map
  from ..utils.nn_architecture_utils import infer_y_range
label_desc: Use image node_id 10 for calling the TabularNeuralNetTorchModel obj's underlying member method code with example usage: obj._fit(X, y, X_val, y_val, time_limit, sample_weight, num_cpus, num_gpus, reporter, verbosity) without return types