class_docstr: This class is an abstract base class (ABC) for models.
  To create a subclass, you need to implement the following five functions:
      -- <__init__>:                      initialize the class; first call BaseModel.__init__(self, opt).
      -- <set_input>:                     unpack data from dataset and apply preprocessing.
      -- <forward>:                       produce intermediate results.
      -- <optimize_parameters>:           calculate losses, gradients, and update network weights.
class_docstr_tok: ["This","class","is","an","abstract","base","class","(","ABC",")","for","models",".","To","create","a","subclass",",","you","need","to","implement","the","following","five","functions",":","--","<","__init__",">",":","initialize","the","class",";","first","call","BaseModel.__init__","(","self",",","opt",")",".","--","<","set_input",">",":","unpack","data","from","dataset","and","apply","preprocessing",".","--","<","forward",">",":","produce","intermediate","results",".","--","<","optimize_parameters",">",":","calculate","losses",",","gradients",",","and","update","network","weights","."]
docstr: Calculate losses, gradients, and update network weights; called in every training iteration
docstr_tok: ["Calculate","losses",",","gradients",",","and","update","network","weights",";","called","in","every","training","iteration"]
code: def optimize_parameters(self, epoch, batch_size):
      """Calculate losses, gradients, and update network weights; called in every training iteration"""
  
      with torch.cuda.amp.autocast(
          enabled=self.is_mixed_precision()
      ):  # enable autocasting if supported
          self.forward(
              epoch=epoch
          )  # first call forward to calculate intermediate results
  
      orig_losses = self._do_scale_loss()  # scale losses if needed
      make_optimizer_step = (
          self._manage_optimizer_zero_grad()
      )  # Accumulate gradient if option is up
      self.backward()  # calculate gradients
      self._do_unscale_loss(orig_losses)  # unscale losses to orig
  
      if self._grad_clip > 0:
          torch.nn.utils.clip_grad_value_(
              self.parameters(), self._grad_clip
          )
  
      if make_optimizer_step:
          self._grad_scale.step(self._optimizer)  # update parameters
  
      if self._lr_scheduler:
          self._do_scheduler_update(
              "_update_lr_scheduler_on",
              self._lr_scheduler,
              epoch,
              batch_size,
          )
  
      if self._bn_scheduler:
          self._do_scheduler_update(
              "_update_bn_scheduler_on",
              self._bn_scheduler,
              epoch,
              batch_size,
          )
  
      self._grad_scale.update()  # update scaling
      self._num_epochs = epoch
      self._num_batches += 1
      self._num_samples += batch_size
  
imports: from collections import OrderedDict
  from abc import abstractmethod
  from typing import Optional, Dict, Any, List
  import os
  import torch
  from torch.optim.optimizer import Optimizer
  from torch.optim.lr_scheduler import _LRScheduler
  import logging
  from collections import defaultdict
  from torch_points3d.core.schedulers.lr_schedulers import instantiate_scheduler
  from torch_points3d.core.schedulers.bn_schedulers import instantiate_bn_scheduler
  from torch_points3d.utils.enums import SchedulerUpdateOn
  from torch_points3d.core.regularizer import *
  from torch_points3d.core.losses import instantiate_loss_or_miner
  from torch_points3d.utils.config import is_dict
  from torch_points3d.utils.colors import colored_print, COLORS
  from .model_interface import TrackerInterface, DatasetInterface, CheckpointInterface
label_desc: Use image node_id 30 for calling the BaseModel obj's underlying member method code with example usage: obj.optimize_parameters(epoch, batch_size) without return types