def transform(self, dataset):
        """Transform labels to integer encodings.

        # Arguments
            dataset: tf.data.Dataset. The dataset to be transformed.

        # Returns
            tf.data.Dataset. The transformed dataset.
        """
        keys_tensor = tf.constant(self.labels)
        vals_tensor = tf.constant(list(range(len(self.labels))))
        table = tf.lookup.StaticHashTable(
            tf.lookup.KeyValueTensorInitializer(keys_tensor, vals_tensor), -1
        )

        return dataset.map(lambda x: table.lookup(tf.reshape(x, [-1])))
Transform labels to integer encodings.

        # Arguments
            dataset: tf.data.Dataset. The dataset to be transformed.

        # Returns
            tf.data.Dataset. The transformed dataset.
        
autokeras/preprocessors/encoders.py