def random_subset(self, relative_size, balance_labels=False, label_list_ids=None):
        """
        Create a subview of random utterances with a approximate size relative to the full corpus.
        By default x random utterances are selected with x equal to ``relative_size * corpus.num_utterances``.

        Args:
            relative_size (float): A value between 0 and 1.
                                   (0.5 will create a subset with approximately 50% of the full corpus size)
            balance_labels (bool): If True, the labels of the selected utterances are balanced as far as possible.
                                   So the count/duration of every label within the subset is equal.
            label_list_ids (list): List of label-list ids. If none is given, all label-lists are considered
                                   for balancing. Otherwise only the ones that are in the list are considered.

        Returns:
            Subview: The subview representing the subset.
        """

        num_utterances_in_subset = round(relative_size * self.corpus.num_utterances)
        all_utterance_ids = sorted(list(self.corpus.utterances.keys()))

        if balance_labels:
            all_label_values = self.corpus.all_label_values(label_list_ids=label_list_ids)
            utterance_with_label_counts = collections.defaultdict(dict)

            for utterance_idx, utterance in self.corpus.utterances.items():
                utterance_with_label_counts[utterance_idx] = utterance.label_count(label_list_ids=label_list_ids)

            subset_utterance_ids = utils.select_balanced_subset(utterance_with_label_counts,
                                                                num_utterances_in_subset,
                                                                list(all_label_values),
                                                                seed=self.rand.random())

        else:
            subset_utterance_ids = self.rand.sample(all_utterance_ids,
                                                    num_utterances_in_subset)

        filter = subview.MatchingUtteranceIdxFilter(utterance_idxs=set(subset_utterance_ids))
        return subview.Subview(self.corpus, filter_criteria=[filter])
Create a subview of random utterances with a approximate size relative to the full corpus.
        By default x random utterances are selected with x equal to ``relative_size * corpus.num_utterances``.

        Args:
            relative_size (float): A value between 0 and 1.
                                   (0.5 will create a subset with approximately 50% of the full corpus size)
            balance_labels (bool): If True, the labels of the selected utterances are balanced as far as possible.
                                   So the count/duration of every label within the subset is equal.
            label_list_ids (list): List of label-list ids. If none is given, all label-lists are considered
                                   for balancing. Otherwise only the ones that are in the list are considered.

        Returns:
            Subview: The subview representing the subset.