docstr: Train a neural network stored in self.network
  Using train_dataloader for training data and
  valid_dataloader for validation.
  
  Parameters
  ----------
  X_train : np.ndarray
      Train set to reconstruct in self supervision
  eval_set : list of np.array
      List of evaluation set
      The last one is used for early stopping
  eval_name : list of str
      List of eval set names.
  eval_metric : list of str
      List of evaluation metrics.
      The last metric is used for early stopping.
  loss_fn : callable or None
      a PyTorch loss function
      should be left to None for self supervised and non experts
  pretraining_ratio : float
      Between 0 and 1, percentage of feature to mask for reconstruction
  weights : np.array
      Sampling weights for each example.
  max_epochs : int
      Maximum number of epochs during training
  patience : int
      Number of consecutive non improving epoch before early stopping
  batch_size : int
      Training batch size
  virtual_batch_size : int
      Batch size for Ghost Batch Normalization (virtual_batch_size < batch_size)
  num_workers : int
      Number of workers used in torch.utils.data.DataLoader
  drop_last : bool
      Whether to drop last batch during training
  callbacks : list of callback function
      List of custom callbacks
  pin_memory: bool
      Whether to set pin_memory to True or False during training
docstr_tok: ["Train","a","neural","network","stored","in","self.network","Using","train_dataloader","for","training","data","and","valid_dataloader","for","validation",".","Parameters","--","--","--","--","--","X_train",":","np.ndarray","Train","set","to","reconstruct","in","self","supervision","eval_set",":","list","of","np.array","List","of","evaluation","set","The","last","one","is","used","for","early","stopping","eval_name",":","list","of","str","List","of","eval","set","names",".","eval_metric",":","list","of","str","List","of","evaluation","metrics",".","The","last","metric","is","used","for","early","stopping",".","loss_fn",":","callable","or","None","a","PyTorch","loss","function","should","be","left","to","None","for","self","supervised","and","non","experts","pretraining_ratio",":","float","Between","0","and","1",",","percentage","of","feature","to","mask","for","reconstruction","weights",":","np.array","Sampling","weights","for","each","example",".","max_epochs",":","int","Maximum","number","of","epochs","during","training","patience",":","int","Number","of","consecutive","non","improving","epoch","before","early","stopping","batch_size",":","int","Training","batch","size","virtual_batch_size",":","int","Batch","size","for","Ghost","Batch","Normalization","(","virtual_batch_size","<","batch_size",")","num_workers",":","int","Number","of","workers","used","in","torch.utils.data.DataLoader","drop_last",":","bool","Whether","to","drop","last","batch","during","training","callbacks",":","list","of","callback","function","List","of","custom","callbacks","pin_memory",":","bool","Whether","to","set","pin_memory","to","True","or","False","during","training"]
code: def fit(
      self,
      X_train,
      eval_set=None,
      eval_name=None,
      loss_fn=None,
      pretraining_ratio=0.5,
      weights=0,
      max_epochs=100,
      patience=10,
      batch_size=1024,
      virtual_batch_size=128,
      num_workers=0,
      drop_last=True,
      callbacks=None,
      pin_memory=True,
      warm_start=False,
  ):
      """Train a neural network stored in self.network
      Using train_dataloader for training data and
      valid_dataloader for validation.
  
      Parameters
      ----------
      X_train : np.ndarray
          Train set to reconstruct in self supervision
      eval_set : list of np.array
          List of evaluation set
          The last one is used for early stopping
      eval_name : list of str
          List of eval set names.
      eval_metric : list of str
          List of evaluation metrics.
          The last metric is used for early stopping.
      loss_fn : callable or None
          a PyTorch loss function
          should be left to None for self supervised and non experts
      pretraining_ratio : float
          Between 0 and 1, percentage of feature to mask for reconstruction
      weights : np.array
          Sampling weights for each example.
      max_epochs : int
          Maximum number of epochs during training
      patience : int
          Number of consecutive non improving epoch before early stopping
      batch_size : int
          Training batch size
      virtual_batch_size : int
          Batch size for Ghost Batch Normalization (virtual_batch_size < batch_size)
      num_workers : int
          Number of workers used in torch.utils.data.DataLoader
      drop_last : bool
          Whether to drop last batch during training
      callbacks : list of callback function
          List of custom callbacks
      pin_memory: bool
          Whether to set pin_memory to True or False during training
      """
      # update model name
  
      self.max_epochs = max_epochs
      self.patience = patience
      self.batch_size = batch_size
      self.virtual_batch_size = virtual_batch_size
      self.num_workers = num_workers
      self.drop_last = drop_last
      self.input_dim = X_train.shape[1]
      self._stop_training = False
      self.pin_memory = pin_memory and (self.device.type != "cpu")
      self.pretraining_ratio = pretraining_ratio
      eval_set = eval_set if eval_set else []
  
      if loss_fn is None:
          self.loss_fn = self._default_loss
      else:
          self.loss_fn = loss_fn
  
      check_input(X_train)
  
      self.update_fit_params(
          weights,
      )
  
      # Validate and reformat eval set depending on training data
      eval_names = validate_eval_set(eval_set, eval_name, X_train)
      train_dataloader, valid_dataloaders = self._construct_loaders(
          X_train, eval_set
      )
  
      if not hasattr(self, "network") or not warm_start:
          # model has never been fitted before of warm_start is False
          self._set_network()
  
      self._update_network_params()
      self._set_metrics(eval_names)
      self._set_optimizer()
      self._set_callbacks(callbacks)
  
      # Call method on_train_begin for all callbacks
      self._callback_container.on_train_begin()
  
      # Training loop over epochs
      for epoch_idx in range(self.max_epochs):
          # Call method on_epoch_begin for all callbacks
          self._callback_container.on_epoch_begin(epoch_idx)
  
          self._train_epoch(train_dataloader)
  
          # Apply predict epoch to all eval sets
          for eval_name, valid_dataloader in zip(
              eval_names, valid_dataloaders
          ):
              self._predict_epoch(eval_name, valid_dataloader)
  
          # Call method on_epoch_end for all callbacks
          self._callback_container.on_epoch_end(
              epoch_idx, logs=self.history.epoch_metrics
          )
  
          if self._stop_training:
              break
  
      # Call method on_train_end for all callbacks
      self._callback_container.on_train_end()
      self.network.eval()
  
imports: import torch
  import numpy
  from torch.utils.data import DataLoader
  from pytorch_tabnet import tab_network
  from pytorch_tabnet.utils import create_explain_matrix, filter_weights, SparsePredictDataset, PredictDataset, check_input, create_group_matrix
  from torch.nn.utils import clip_grad_norm_
  from pytorch_tabnet.pretraining_utils import create_dataloaders, validate_eval_set
  from pytorch_tabnet.metrics import UnsupMetricContainer, check_metrics, UnsupervisedLoss
  from pytorch_tabnet.abstract_model import TabModel
  import scipy
label_desc: Use image node_id 5 for calling the TabNetPretrainer obj's underlying member method code with example usage: obj.fit(X_train, eval_set, eval_name, loss_fn, pretraining_ratio, weights, max_epochs, patience, batch_size, virtual_batch_size, num_workers, drop_last, callbacks, pin_memory, warm_start) without return types