"""Training action for {{ name }}."""

from __future__ import annotations


def train(run, dataset, hyperparameter, checkpoint=None):
    """Train the model.

    Args:
        run: Run context for logging metrics and progress.
        dataset: Training dataset.
        hyperparameter: Training hyperparameters.
        checkpoint: Optional checkpoint to resume from.

    Returns:
        Path to saved model weights.
    """
    epochs = hyperparameter.get('epochs', 10)
    batch_size = hyperparameter.get('batch_size', 32)
    learning_rate = hyperparameter.get('learning_rate', 0.001)

    run.set_progress(0, epochs, category='train')

    for epoch in range(1, epochs + 1):
        # TODO: Implement your training loop here
        loss = 1.0 / epoch  # Placeholder
        accuracy = epoch / epochs  # Placeholder

        run.log_metric('epoch', epoch, loss=loss, accuracy=accuracy)
        run.set_progress(epoch, epochs, category='train')

    # Return path to saved model
    return './'
