docstr: Compute depth metrics, to allow monitoring during training
  
  This isn't particularly accurate as it averages over the entire batch,
  so is only used to give an indication of validation performance
docstr_tok: ["Compute","depth","metrics",",","to","allow","monitoring","during","training","This","is","n't","particularly","accurate","as","it","averages","over","the","entire","batch",",","so","is","only","used","to","give","an","indication","of","validation","performance"]
code: def compute_metrics(self, inputs, outputs, depth_metrics):
      """Compute depth metrics, to allow monitoring during training
  
      This isn't particularly accurate as it averages over the entire batch,
      so is only used to give an indication of validation performance
      """
      depth_gt = inputs["depth_gt"].asnumpy()
      gt_height, gt_width = depth_gt.shape[2:]
  
      depth_pred = outputs[("depth", 0, 0)]
      depth_pred = mx.nd.clip(
          mx.nd.contrib.BilinearResize2D(
              depth_pred, height=gt_height, width=gt_width
          ),
          a_min=1e-3,
          a_max=80,
      )
      depth_pred = depth_pred.detach().asnumpy()
  
      # garg/eigen crop
      mask = depth_gt > 0
      crop_mask = np.zeros_like(mask)
      crop_mask[:, :, 153:371, 44:1197] = 1
      mask = np.logical_and(mask, crop_mask)
  
      depth_gt = depth_gt[mask]
      depth_pred = depth_pred[mask]
  
      if self.opt.use_stereo:
          scale_factor = STEREO_SCALE_FACTOR
      else:
          scale_factor = np.median(depth_gt) / np.median(depth_pred)
      depth_pred *= scale_factor
  
      depth_pred = np.clip(depth_pred, a_min=1e-3, a_max=80)
  
      depth_errors = compute_depth_errors(depth_gt, depth_pred)
  
      for i, metric in enumerate(self.depth_metric_names):
          depth_metrics[metric] += depth_errors[i]
  
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 10 for calling the Trainer obj's underlying member method code with example usage: obj.compute_metrics(inputs, outputs, depth_metrics) without return types