code: def losses(self):
      collected_losses = []
      for loss in self._losses.values():
          collected_losses.append(loss)
  
      for child in self.children():
          if isinstance(child, LudwigModule):
              collected_losses.extend(child.losses())
          elif isinstance(child, ModuleDict):
              for c in child.values():
                  if hasattr(
                      c, "losses"
                  ):  # Some modules, i.e. SequenceReducers, don't have losses.
                      collected_losses.extend(c.losses())
          elif isinstance(child, Module):
              pass
          else:
              raise ValueError
  
      return collected_losses
  
imports: import math
  import os
  import warnings
  from abc import abstractmethod
  from functools import lru_cache
  from typing import List, Optional, Tuple, Union
  import torch
  from torch import nn
  from torch.nn import Module, ModuleDict
  from ludwig.api_annotations import DeveloperAPI
  from ludwig.constants import ENCODER_OUTPUT
  from ludwig.utils.strings_utils import SpecialSymbol
label_desc: Use image node_id 4 for calling the LudwigModule obj's underlying member method code with example usage: obj.losses() and returns: collected_losses