code: def training_model(
      model: torch.nn.Module,
      optimizer: Union[Optimizer, List[Optimizer]],
      training_step: _TRAINING_STEP,
      scheduler: Union[None, SCHEDULER, List[SCHEDULER]] = None,
      max_steps: Union[int, None] = None,
      max_epochs: Union[int, None] = None,
  ):
      model.train()
      max_epochs = (
          max_epochs if max_epochs else 10 if max_steps is None else 100
      )
      current_steps = 0
      best_acc = 0.0
  
      # training
      for epoch in range(max_epochs):
          print(f"Epoch {epoch} start!")
          for batch in train_dataloader:
              if isinstance(optimizer, Optimizer):
                  optimizer.zero_grad()
              elif isinstance(optimizer, List) and all(
                  isinstance(_, Optimizer) for _ in optimizer
              ):
                  for opt in optimizer:
                      opt.zero_grad()
              loss = training_step(batch, model)
              assert isinstance(loss, torch.Tensor)
              loss.backward()
              if isinstance(optimizer, Optimizer):
                  optimizer.step()
              elif isinstance(optimizer, List) and all(
                  isinstance(_, Optimizer) for _ in optimizer
              ):
                  for opt in optimizer:
                      opt.step()
              if isinstance(scheduler, SCHEDULER):
                  scheduler.step()
              if isinstance(scheduler, List) and all(
                  isinstance(_, SCHEDULER) for _ in scheduler
              ):
                  for sch in scheduler:
                      sch.step()
              current_steps += 1
              if max_steps and current_steps == max_steps:
                  return
  
          acc = evaluating_model(model)
          best_acc = max(acc, best_acc)
          print(f"epoch={epoch}\tacc={acc}\tbest_acc={best_acc}")
  
imports: import functools
  from typing import Callable, Union, List, Tuple, Any, Dict
  import torch
  import torch.nn.functional
  from torch.optim import Optimizer
  from torch.utils.data import DataLoader
  from torch import Tensor
  from torchvision import datasets, transforms
  import nni
  from nni.compression.quantization import PtqQuantizer
  from nni.compression.utils import TorchEvaluator
  from nni.common.types import SCHEDULER
label_desc: Use image node_id 2 for calling a global function with example usage: training_model(model, optimizer, training_step, scheduler, max_steps, max_epochs) without return types