class_docstr: Generic PyTorch-Lightning class that must be initialized with a PyTorch module.
class_docstr_tok: ["Generic","PyTorch-Lightning","class","that","must","be","initialized","with","a","PyTorch","module","."]
docstr: Total training steps inferred from datamodule and devices.
docstr_tok: ["Total","training","steps","inferred","from","datamodule","and","devices","."]
code: def num_training_steps(self) -> int:
      """Total training steps inferred from datamodule and devices."""
      if (
          isinstance(self.trainer.limit_train_batches, int)
          and self.trainer.limit_train_batches != 0
      ):
          dataset_size = self.trainer.limit_train_batches
      elif isinstance(self.trainer.limit_train_batches, float):
          # limit_train_batches is a percentage of batches
          dataset_size = len(self.trainer.datamodule.train_dataloader())
          dataset_size = int(
              dataset_size * self.trainer.limit_train_batches
          )
      else:
          dataset_size = len(self.trainer.datamodule.train_dataloader())
  
      num_devices = max(
          1, self.trainer.num_gpus, self.trainer.num_processes
      )
      if self.trainer.tpu_cores:
          num_devices = max(num_devices, self.trainer.tpu_cores)
  
      effective_batch_size = (
          self.trainer.accumulate_grad_batches * num_devices
      )
      max_estimated_steps = (
          dataset_size // effective_batch_size
      ) * self.trainer.max_epochs
  
      if (
          self.trainer.max_steps
          and self.trainer.max_steps < max_estimated_steps
      ):
          return self.trainer.max_steps
      return max_estimated_steps
  
file_path: DeepKE/src/deepke/relation_extraction/few_shot/lit_models/base.py
imports: import torch
  from transformers.optimization import get_linear_schedule_with_warmup
  from torch import nn
label_desc: Use image node_id 9 for calling the BaseLitModel obj's underlying member method code with example usage: obj.num_training_steps() and returns: max_estimated_steps, self