'Helper function to estimate label shape'

def _estimate_label_shape(self):

    max_count = 0
    self.reset()
    try:
        while True:
            (label, _) = self.next_sample()
            label = self._parse_label(label)
            max_count = max(max_count, label.shape[0])
    except StopIteration:
        pass
    self.reset()
    return (max_count, label.shape[1])
