docstr: Compute the reprojection and smoothness losses for a minibatch
          
docstr_tok: ["Compute","the","reprojection","and","smoothness","losses","for","a","minibatch"]
code: def compute_losses(self, inputs, outputs):
      """Compute the reprojection and smoothness losses for a minibatch"""
      losses = {}
      total_loss = 0
  
      for scale in self.opt.scales:
          loss = 0
          reprojection_losses = []
  
          if self.opt.v1_multiscale:
              source_scale = scale
          else:
              source_scale = 0
  
          disp = outputs[("disp", scale)]
          color = inputs[("color", 0, scale)]
          target = inputs[("color", 0, source_scale)]
  
          for frame_id in self.opt.frame_ids[1:]:
              pred = outputs[("color", frame_id, scale)]
              reprojection_losses.append(
                  self.compute_reprojection_loss(pred, target)
              )
  
          reprojection_losses = mx.nd.concat(
              *reprojection_losses, dim=1
          )
  
          if not self.opt.disable_automasking:
              identity_reprojection_losses = []
              for frame_id in self.opt.frame_ids[1:]:
                  pred = inputs[("color", frame_id, source_scale)]
                  identity_reprojection_losses.append(
                      self.compute_reprojection_loss(pred, target)
                  )
  
              identity_reprojection_losses = mx.nd.concat(
                  *identity_reprojection_losses, dim=1
              )
  
              if self.opt.avg_reprojection:
                  identity_reprojection_loss = (
                      identity_reprojection_losses.mean(
                          axis=1, keepdims=True
                      )
                  )
              else:
                  # save both images, and do min all at once below
                  identity_reprojection_loss = (
                      identity_reprojection_losses
                  )
  
          if self.opt.avg_reprojection:
              reprojection_loss = reprojection_losses.mean(
                  axis=1, keepdims=True
              )
          else:
              reprojection_loss = reprojection_losses
  
          if not self.opt.disable_automasking:
              # add random numbers to break ties
              identity_reprojection_loss = (
                  identity_reprojection_loss
                  + mx.nd.random.randn(
                      *identity_reprojection_loss.shape
                  ).as_in_context(identity_reprojection_loss.context)
                  * 0.00001
              )
  
              combined = mx.nd.concat(
                  identity_reprojection_loss, reprojection_loss, dim=1
              )
          else:
              combined = reprojection_loss
  
          if combined.shape[1] == 1:
              to_optimise = combined
          else:
              to_optimise = mx.nd.min(data=combined, axis=1)
              idxs = mx.nd.argmin(data=combined, axis=1)
  
          if not self.opt.disable_automasking:
              outputs["identity_selection/{}".format(scale)] = (
                  idxs > identity_reprojection_loss.shape[1] - 1
              ).astype("float")
  
          loss += to_optimise.mean()
  
          mean_disp = disp.mean(axis=2, keepdims=True).mean(
              axis=3, keepdims=True
          )
          norm_disp = disp / (mean_disp + 1e-7)
  
          smooth_loss = get_smooth_loss(norm_disp, color)
  
          loss = loss + self.opt.disparity_smoothness * smooth_loss / (
              2**scale
          )
          total_loss = total_loss + loss
          losses["loss/{}".format(scale)] = loss
  
      total_loss = total_loss / self.num_scales
      losses["loss"] = total_loss
      return losses
  
imports: from __future__ import absolute_import, division, print_function
  import os
  import sys
  import shutil
  import copy
  from tqdm import tqdm
  import numpy
  import json
  import mxnet
  from mxnet import gluon, autograd
  from gluoncv.data import KITTIRAWDataset, KITTIOdomDataset
  from gluoncv.data.kitti.kitti_utils import dict_batchify_fn, readlines
  from gluoncv.model_zoo import get_model
  from gluoncv.model_zoo.monodepthv2.layers import *
  from gluoncv.model_zoo.monodepthv2 import MonoDepth2PoseNet
  from gluoncv.utils import LRScheduler, LRSequential
label_desc: Use image node_id 9 for calling the Trainer obj's underlying member method code with example usage: obj.compute_losses(inputs, outputs) and returns: losses