def _count_far_pp(x):
    """Counts objects far from the camera."""
    # Threshold removes ~half of the objects.
    # Count distribution (thresholded at 15):

    # Location feature contains (x, y, z) in meters w.r.t. the camera.
    distant_objects = tf.where(x['objects']['location'][:, 2] >= 25)
    label = tf.math.minimum(tf.size(distant_objects), 8)
    return {'image': x['image'], 'label': label}
Counts objects far from the camera.
clip_benchmark/clip_benchmark/datasets/kitti.py