def compute_depth_errors(depth_pred, depth_gt, valid_mask):
    """
    Computes different distance measures between two depth maps.

    depth_pred:           depth map prediction
    depth_gt:             depth map ground truth
    distances_to_compute: which distances to compute

    Returns:
        a dictionary with computed distances, and the number of valid pixels

    """
    depth_pred = depth_pred[valid_mask]
    depth_gt = depth_gt[valid_mask]
    num_valid = np.sum(valid_mask)

    distances_to_compute = ['l1',
                            'l1_inverse',
                            'scale_invariant',
                            'abs_relative',
                            'sq_relative',
                            'avg_log10',
                            'rmse_log',
                            'rmse',
                            'ratio_threshold_1.25',
                            'ratio_threshold_1.5625',
                            'ratio_threshold_1.953125']

    results = {'num_valid': num_valid}
    for dist in distances_to_compute:
        if dist.startswith('ratio_threshold'):
            threshold = float(dist.split('_')[-1])
            results[dist] = ratio_threshold(depth_pred, depth_gt, threshold)
        else:
            results[dist] = globals()[dist](depth_pred, depth_gt)

    return results

    Computes different distance measures between two depth maps.

    depth_pred:           depth map prediction
    depth_gt:             depth map ground truth
    distances_to_compute: which distances to compute

    Returns:
        a dictionary with computed distances, and the number of valid pixels

    
mv-diffusion/One-2-3-45-by-view/reconstruction/loss/depth_metric.py