class_docstr: CenterNet network using Hourglass from https://arxiv.org/abs/1904.07850S.
class_docstr_tok: ["CenterNet","network","using","Hourglass","from","https",":","\/\/arxiv.org\/abs\/1904.07850S","."]
docstr: Compute loss.
docstr_tok: ["Compute","loss","."]
code: def compute_loss(self, sample, normalized_sample, outputs):
      """Compute loss."""
      if sample == 0:
          print("Nothing.")
  
      total_loss = 0
      per_output_per_head_loss = collections.defaultdict(float)
  
      if self.heads_losses is not None:
          (
              image_loss,
              per_output_per_head_image_loss,
          ) = self._compute_loss(
              outputs,
              normalized_sample,
              self.heads_losses,
              self.batch_size,
          )
          total_loss += image_loss
          per_output_per_head_loss = self.merge_per_head_losses(
              per_output_per_head_loss, per_output_per_head_image_loss
          )
  
      if self.network.losses:
          regularization_loss = tf.reduce_mean(
              tf.stack(self.network.losses, axis=0)
          )
          per_output_per_head_loss[
              "regularization"
          ] = regularization_loss
          total_loss += regularization_loss
      return total_loss, per_output_per_head_loss
  
imports: import collections
  import os
  import random
  import string
  import time
  from absl import logging
  import numpy
  import tensorflow
  from tensorflow_graphics.projects.points_to_3Dobjects.models import centernet_utils
  from tensorflow_graphics.projects.points_to_3Dobjects.networks import hourglass
  from tensorflow_graphics.projects.points_to_3Dobjects.transforms import transforms
  from tensorflow_graphics.projects.points_to_3Dobjects.utils import image
  from google3.pyglib import gfile
label_desc: Use image node_id 8 for calling the CenterNetVID obj's underlying member method code with example usage: obj.compute_loss(sample, normalized_sample, outputs) and returns: total_loss,  per_output_per_head_loss