human
Solve the following python programming problem given the following code:
# Example training data, of dtype `string`.
samples = np.array([["This is the 1st sample."], ["And here's the 2nd sample."]])
labels = [[0], [1]]

# Prepare a TextVectorization layer.
vectorizer = TextVectorization(output_mode="int")
vectorizer.adapt(samples)

# Asynchronous preprocessing: the text vectorization is part of the tf.data pipeline.
# First, create a dataset
dataset = tf.data.Dataset.from_tensor_slices((samples, labels)).batch(2)
# Apply text vectorization to the samples
dataset = dataset.map(lambda x, y: (vectorizer(x), y))
# Prefetch with a buffer size of 2 batches
dataset = dataset.prefetch(2)

# Our model should expect sequences of integers as inputs
inputs = keras.Input(shape=(None,), dtype="int64")
x = layers.Embedding(input_dim=10, output_dim=32)(inputs)
outputs = layers.Dense(1)(x)
model = keras.Model(inputs, outputs)

model.compile(optimizer="adam", loss="mse", run_eagerly=True)
model.fit(dataset)
Given the above code, generate some markdown instructions for it.
assistant
#Here is the Python program you requested.

fit()中使用自定义的训练步骤training step
默认设置，fit()是配置为监督学习环境。如果需要不同的训练过程（如对抗网络GAN的训练循环），可以提供自定义的实现Model.train_step()，keras内部fit()方法会重复的调用该方法。
Metrics, callbacks,可以如常工作
下面是重新实现 fit()：
``python
class CustomModel(keras.Model):
  def train_step(self, data):
    # Unpack the data. Its structure depends on your model and
    # on what you pass tofit().
    x, y = data
    with tf.GradientTape() as tape:
      y_pred = self(x, training=True)  # Forward pass
      # Compute the loss value
      # (the loss function is configured incompile()`)
      loss = self.compiled_loss(y, y_pred,regularization_losses=self.losses)
# Compute gradients
trainable_vars = self.trainable_variables
gradients = tape.gradient(loss, trainable_vars)
# Update weights
self.optimizer.apply_gradients(zip(gradients, trainable_vars))
# Update metrics (includes the metric that tracks the loss)
self.compiled_metrics.update_state(y, y_pred)
# Return a dict mapping metric names to current value
return {m.name: m.result() for m in self.metrics}

Construct and compile an instance of CustomModel
inputs = keras.Input(shape=(32,))
outputs = keras.layers.Dense(1)(inputs)
model = CustomModel(inputs, outputs)
model.compile(optimizer='adam', loss='mse', metrics=[...])
Just use fit as usual
model.fit(dataset, epochs=3, callbacks=...)
```
想更深入请看:
"Customizing what happens in fit()".
使用即可执行eager execution来调试你的模型
如果自定义training steps or custom layers，通常需要对其进行调试。
The debugging experience is an integral part of a framework: with Keras, the debugging
 workflow is designed with the user in mind.
默认情况下，keras模型会编译成高度优化的计算图，执行速度更快。也就是说模型中所写的python code(e.g. in a custom train_step)，并不是实际执行的code。这使得debug较为困难
通城Debugging最后能一步一步的执行，大家都喜欢用print(打印出过程信息)，设置你还想用pdb。这时我们需要使用即可执行eager execution模型，如下：
参数设置 run_eagerly=True，在 compile()方法中:
python
model.compile(optimizer='adam', loss='mse', run_eagerly=True)
当然，该中方法的不足是模型要显著的慢一些。当模型完成调试时，正式训练时还是建议使用计算图模式。
使用多GPU加速训练
tf Keras 自带工业级的多GPU支持，和分布式multi-worker训练。通过 tf.distribute API实现.
如果你的机器上有多个GPU，可以同时使用所有GPU训练模型：

创建...