class_docstr: Transform labels to encodings.
  
  # Arguments
      labels: A list of labels of any type. The labels to be encoded.
class_docstr_tok: ["Transform","labels","to","encodings",".","#","Arguments","labels",":","A","list","of","labels","of","any","type",".","The","labels","to","be","encoded","."]
docstr: Transform labels to integer encodings.
  
  # Arguments
      dataset: tf.data.Dataset. The dataset to be transformed.
  
  # Returns
      tf.data.Dataset. The transformed dataset.
docstr_tok: ["Transform","labels","to","integer","encodings",".","#","Arguments","dataset",":","tf.data.Dataset",".","The","dataset","to","be","transformed",".","#","Returns","tf.data.Dataset",".","The","transformed","dataset","."]
code: 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])))
  
file_path: autokeras/autokeras/preprocessors/encoders.py
imports: import numpy
  import tensorflow
  from autokeras.engine import preprocessor
label_desc: Use image node_id 4 for calling the Encoder obj's underlying member method code with example usage: obj.transform(dataset) and returns: dataset