# Path: snntoolbox/datasets/utils.py
# def to_categorical(y, nb_classes):
#     """Convert class vector to binary class matrix.
# 
#     If the input ``y`` has shape (``nb_samples``,) and contains integers from 0
#     to ``nb_classes``, the output array will be of dimension
#     (``nb_samples``, ``nb_classes``).
#     """
# 
#     y = np.asarray(y, dtype='int32')
#     y_cat = np.zeros((len(y), nb_classes))
#     for i in range(len(y)):
#         y_cat[i, y[i]] = 1.
#     return y_cat


import os
import numpy as np
from collections import deque
from more_itertools import unique_everseen
from snntoolbox.datasets.utils import to_categorical
    from snntoolbox.datasets.aedat import ImportAedat
        # Load new sequence.
        filepath = os.path.join(self.dataset_path,
                                self.filenames[self.dvs_sample_idx])
        event_list = load_event_list(filepath, self.chip_size)

        # Update statistics of current sequence.
        self.num_events_of_sample = len(event_list)
        print("Total number of events of this sample: {}.".format(
            self.num_events_of_sample))
        print("Number of batches: {}.".format(
            self.num_events_of_sample // self.num_events_per_batch + 1))

        # Reset batch index, because new sequence will be used to generate new
        # batches.
        self.batch_idx = 0

        return event_list

    def next_sequence_batch(self):
        """
        Get a new batch of event sequences by chopping a long sequence into
        pieces.
        """

        # Load new sequence if all events of current sequence have been used.
        if self.num_events_of_sample <= \
                self.num_events_per_batch * (self.batch_idx + 1):
            self.event_sequence = self.next_sequence()

            # Get class label, which is the same for all events in a sequence.

# Path: snntoolbox/datasets/utils.py
# def to_categorical(y, nb_classes):
#     """Convert class vector to binary class matrix.
# 
#     If the input ``y`` has shape (``nb_samples``,) and contains integers from 0
#     to ``nb_classes``, the output array will be of dimension
#     (``nb_samples``, ``nb_classes``).
#     """
# 
#     y = np.asarray(y, dtype='int32')
#     y_cat = np.zeros((len(y), nb_classes))
#     for i in range(len(y)):
#         y_cat[i, y[i]] = 1.
#     return y_cat


# Path: snntoolbox/datasets/aedat/DVSIterator.py
import os
import numpy as np
from collections import deque
from more_itertools import unique_everseen
from snntoolbox.datasets.utils import to_categorical
    from snntoolbox.datasets.aedat import ImportAedat

        # Load new sequence.
        filepath = os.path.join(self.dataset_path,
                                self.filenames[self.dvs_sample_idx])
        event_list = load_event_list(filepath, self.chip_size)

        # Update statistics of current sequence.
        self.num_events_of_sample = len(event_list)
        print("Total number of events of this sample: {}.".format(
            self.num_events_of_sample))
        print("Number of batches: {}.".format(
            self.num_events_of_sample // self.num_events_per_batch + 1))

        # Reset batch index, because new sequence will be used to generate new
        # batches.
        self.batch_idx = 0

        return event_list

    def next_sequence_batch(self):
        """
        Get a new batch of event sequences by chopping a long sequence into
        pieces.
        """

        # Load new sequence if all events of current sequence have been used.
        if self.num_events_of_sample <= \
                self.num_events_per_batch * (self.batch_idx + 1):
            self.event_sequence = self.next_sequence()

            # Get class label, which is the same for all events in a sequence.

            self.y_b = np.broadcast_to(to_categorical(