import tensorflow as tf

    labeled_boxes_init = tf.gather(
      sample['groundtruth_boxes'], axis=1, indices=[1, 0, 3, 2]) * 256.0

    for _, metric in self.metrics.items():
      if isinstance(metric, ShapeAccuracyMetric):
        labels = sample['shapes']
        weights = tf.math.sign(labels + 1)  # -1 is mapped to zero, else 1
        metric.update(labels, detections['shapes_logits'], weights)
      elif isinstance(metric, BoxIoUMetric):
        scene_id = str(sample['scene_filename'].numpy(), 'utf-8')

        # Get ground truth boxes
        labeled_boxes = labeled_boxes_init
        if metric.threed:
          rotations_y = tf.concat([tf_utils.euler_from_rotation_matrix(
              tf.reshape(detections['rotations_3d'][i], [3, 3]),
              1) for i in range(num_boxes)], axis=0)
          rotations_y = tf.reshape(rotations_y, [-1, 1])
          labeled_boxes = tf.concat([sample['translations_3d'],
                                     sample['sizes_3d'],
                                     rotations_y], axis=1)

        # Get predicted boxes
        predicted_boxes = detections['detection_boxes']
        if metric.threed:
          rotations_y = tf.concat([tf_utils.euler_from_rotation_matrix(
              tf.reshape(detections['rotations_3d'][i], [3, 3]),
              1) for i in range(num_boxes)], axis=0)
          rotations_y = tf.reshape(rotations_y, [-1, 1])
          predicted_boxes = tf.concat([detections['translations_3d'],
