'Helper function to parse object detection label.
Format for raw label:
n        k       ...     [id     xmin    ymin    xmax    ymax    ...]    [repeat]
where n is the width of header, 2 or larger
k is the width of each object annotation, can be arbitrary, at least 5'

def _parse_label(self, label):

    if isinstance(label, nd.NDArray):
        label = label.asnumpy()
    raw = label.ravel()
    if (raw.size < 7):
        raise RuntimeError(('Label    shape    is    invalid:    ' + str(raw.shape)))
    header_width = int(raw[0])
    obj_width = int(raw[1])
    if (((raw.size - header_width) % obj_width) != 0):
        msg = ('Label    shape    %s    inconsistent    with    annotation    width    %d.' % str(raw.shape, obj_width))
        raise RuntimeError(msg)
    out = np.reshape(raw[header_width:], ((-1), obj_width))
    valid = np.where(np.logical_and((out[:, 3] > out[:, 1]), (out[:, 4] > out[:, 2])))[0]
    if (valid.size < 1):
        raise RuntimeError('Encounter    sample    with    no    valid    label.')
    return out[valid, :]
