code: def fit(
      self,
      train_dataset,
      valid_dataset=None,
      train_sampler=None,
      valid_sampler=None,
      device="cuda",
      epochs=10,
      train_bs=16,
      valid_bs=16,
      n_jobs=8,
      callbacks=None,
      fp16=False,
      train_collate_fn=None,
      valid_collate_fn=None,
      train_shuffle=True,
      valid_shuffle=False,
      accumulation_steps=1,
      clip_grad_norm=None,
  ):
      print(
          "NOTE: This is old Model class and is deprecated. It will no longer be maintained! Please use version > 0.5.1. Its much better and supports multi-gpu training too!"
      )
      """
          The model fit function. Heavily inspired by tf/keras, this function is the core of Tez and this is the only
          function you need to train your models.
  
          """
      if device == "tpu":
          if XLA_AVAILABLE is False:
              raise RuntimeError(
                  "XLA is not available. Please install pytorch_xla"
              )
          else:
              self.using_tpu = True
              fp16 = False
              device = xm.xla_device()
      self._init_model(
          device=device,
          train_dataset=train_dataset,
          valid_dataset=valid_dataset,
          train_sampler=train_sampler,
          valid_sampler=valid_sampler,
          train_bs=train_bs,
          valid_bs=valid_bs,
          n_jobs=n_jobs,
          callbacks=callbacks,
          fp16=fp16,
          train_collate_fn=train_collate_fn,
          valid_collate_fn=valid_collate_fn,
          train_shuffle=train_shuffle,
          valid_shuffle=valid_shuffle,
          accumulation_steps=accumulation_steps,
          clip_grad_norm=clip_grad_norm,
      )
  
      for _ in range(epochs):
          self.train_state = enums.TrainingState.EPOCH_START
          self.train_state = enums.TrainingState.TRAIN_EPOCH_START
          train_loss = self.train_one_epoch(self.train_loader)
          self.train_state = enums.TrainingState.TRAIN_EPOCH_END
          if self.valid_loader:
              self.train_state = enums.TrainingState.VALID_EPOCH_START
              valid_loss = self.validate_one_epoch(self.valid_loader)
              self.train_state = enums.TrainingState.VALID_EPOCH_END
          if self.scheduler:
              if self.step_scheduler_after == "epoch":
                  if self.step_scheduler_metric is None:
                      self.scheduler.step()
                  else:
                      step_metric = self.name_to_metric(
                          self.step_scheduler_metric
                      )
                      self.scheduler.step(step_metric)
          self.train_state = enums.TrainingState.EPOCH_END
          if self._model_state.value == "end":
              break
          self.current_epoch += 1
      self.train_state = enums.TrainingState.TRAIN_END
  
imports: import warnings
  import psutil
  import torch
  import torch.nn
  from tqdm import tqdm
  from tez import enums
  from tez.callbacks import CallbackRunner
  from tez.utils import AverageMeter
label_desc: Use image node_id 24 for calling the Model obj's underlying member method code with example usage: obj.fit(train_dataset, valid_dataset, train_sampler, valid_sampler, device, epochs, train_bs, valid_bs, n_jobs, callbacks, fp16, train_collate_fn, valid_collate_fn, train_shuffle, valid_shuffle, accumulation_steps, clip_grad_norm) without return types