//  [python]
def test_model_with_multiple_tasks_metrics(
    music_streaming_data: Dataset, run_eagerly: bool, metrics
):
    music_streaming_data.schema = music_streaming_data.schema.without("play_percentage")

    inputs = mm.InputBlockV2(music_streaming_data.schema)
    prediction_tasks = mm.PredictionTasks(music_streaming_data.schema)
    model = mm.Model(inputs, mm.MLPBlock([64]), prediction_tasks)

    weighted_metrics = metrics

    expected_metrics = [
        "loss",
        "regularization_loss",
        "loss_batch",
        "click/binary_classification_task_loss",
        "like/binary_classification_task_loss",
    ]
    if isinstance(metrics, Metric):
        expected_metrics.extend(
            [
                "click/binary_classification_task_auc",
                "like/binary_classification_task_auc",
                "click/binary_classification_task_weighted_auc",
                "like/binary_classification_task_weighted_auc",
            ]
        )

        # Creating another copy of the metrics to avoid error for reusing same metrics
        # for metrics and weighted_metrics
        weighted_metrics = (tf.keras.metrics.AUC(name="auc"),)
    elif isinstance(metrics, (list, tuple)):
        expected_metrics.extend(
            [
                "click/binary_classification_task_precision",
                "like/binary_classification_task_precision",
                "click/binary_classification_task_recall",
                "like/binary_classification_task_recall",
                "click/binary_classification_task_weighted_precision",
                "like/binary_classification_task_weighted_precision",
                "click/binary_classification_task_weighted_recall",
                "like/binary_classification_task_weighted_recall",
            ]
        )
    elif isinstance(metrics, dict):
        expected_metrics.extend(
            [
                "click/binary_classification_task_precision",
                "click/binary_classification_task_recall",
                "like/binary_classification_task_binary_accuracy",
                "click/binary_classification_task_weighted_precision",
                "click/binary_classification_task_weighted_recall",
                "like/binary_classification_task_weighted_binary_accuracy",
            ]
        )
        # Creating another copy of the metrics to avoid error for reusing same metrics
        # for metrics and weighted_metrics
        weighted_metrics = {
            "click/binary_classification_task": (
                tf.keras.metrics.Precision(name="precision"),
                tf.keras.metrics.Recall(name="recall"),
            ),
            "like/binary_classification_task": [
                tf.keras.metrics.BinaryAccuracy(name="binary_accuracy")
            ],
        }
    elif metrics is None:
        # Use default metrics
        expected_metrics.extend(
            [
                "click/binary_classification_task_precision",
                "click/binary_classification_task_recall",
                "click/binary_classification_task_binary_accuracy",
                "click/binary_classification_task_auc",
                "like/binary_classification_task_precision",
                "like/binary_classification_task_recall",
                "like/binary_classification_task_binary_accuracy",
                "like/binary_classification_task_auc",
            ]
        )

    model.compile(
        optimizer="adam",
        run_eagerly=run_eagerly,
        metrics=metrics,
        weighted_metrics=weighted_metrics,
        from_serialized=False,
    )

    metrics_results = model.train_step(
        mm.sample_batch(music_streaming_data, batch_size=50, prepare_features=False)
    )

    assert metrics_results["loss"] >= 0
    assert set(metrics_results.keys()) == set(expected_metrics)