original_docstring:  Perform one training step for the model.
      Args:
        model       : Keras model to train.
        loss_fn     : Loss function to use.
        optimizer_fn: Optimizer function to use.
        metric      : keras.metric to use.
        image       : Tensor of training images of shape [batch_size, 28, 28, 1].
        label       : Tensor of class labels of shape [batch_size, ]
    
docstring: Perform one training step for the model.
docstring_tokens: Perform one training step for the model .
code: def train_step(model, loss_fn, optimizer_fn, metric, image, label):
    """ Perform one training step for the model.
      Args:
        model       : Keras model to train.
        loss_fn     : Loss function to use.
        optimizer_fn: Optimizer function to use.
        metric      : keras.metric to use.
        image       : Tensor of training images of shape [batch_size, 28, 28, 1].
        label       : Tensor of class labels of shape [batch_size, ]
    """
    with tf.GradientTape() as tape:
      preds = model(image)
      label_onehot = tf.one_hot(label, 10)
      loss_ = loss_fn(label_onehot, preds)
    grads = tape.gradient(loss_, model.trainable_variables)
    optimizer_fn.apply_gradients(zip(grads, model.trainable_variables))
    metric(loss_)
code_tokens: def train_step ( model , loss_fn , optimizer_fn , metric , image , label ) : with tf . GradientTape ( ) as tape : preds = model ( image ) label_onehot = tf . one_hot ( label , 10 ) loss_ = loss_fn ( label_onehot , preds ) grads = tape . gradient ( loss_ , model . trainable_variables ) optimizer_fn . apply_gradients ( zip ( grads , model . trainable_variables ) ) metric ( loss_ )
short_docstring: Perform one training step for the model.
short_docstring_tokens: Perform one training step for the model .
comment: """ Perform one training step for the model.
      Args:
        model       : Keras model to train.
        loss_fn     : Loss function to use.
        optimizer_fn: Optimizer function to use.
        metric      : keras.metric to use.
        image       : Tensor of training images of shape [batch_size, 28, 28, 1].
        label       : Tensor of class labels of shape [batch_size, ]
    """