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: Modules which have internal losses return a dict of the form
  {<loss_name>: <loss>}
  This method merges the dicts of all child modules with internal loss
  and returns this merged dict
docstr_tok: ["Modules","which","have","internal","losses","return","a","dict","of","the","form","{","<","loss_name",">",":","<","loss",">","}","This","method","merges","the","dicts","of","all","child","modules","with","internal","loss","and","returns","this","merged","dict"]
code: def get_named_internal_losses(self):
      """
      Modules which have internal losses return a dict of the form
      {<loss_name>: <loss>}
      This method merges the dicts of all child modules with internal loss
      and returns this merged dict
      """
      losses_global = defaultdict(list)
  
      def search_from_key(modules, losses_global):
          for _, module in modules.items():
              if isinstance(module, BaseInternalLossModule):
                  losses = module.get_internal_losses()
                  for loss_name, loss_value in losses.items():
                      if torch.is_tensor(loss_value):
                          assert loss_value.dim() == 0
                          losses_global[loss_name].append(loss_value)
                      elif isinstance(loss_value, float):
                          losses_global[loss_name].append(
                              torch.tensor(loss_value).to(self.device)
                          )
                      else:
                          raise ValueError(
                              "Unsupported value type for a loss: {}".format(
                                  loss_value
                              )
                          )
              search_from_key(module._modules, losses_global)
  
      search_from_key(self._modules, losses_global)
      return losses_global
  
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 34 for calling the BaseModel obj's underlying member method code with example usage: obj.get_named_internal_losses() and returns: losses_global