def eval(model: ICMNetwork, states: Tensor, actions: Tensor, next_states: Tensor) -> float:
    """
    **Overview**:
        Evaluation function for the ICM model.
    """
    with torch.no_grad():
        # Perform a forward pass through the network.
        real_next_state_feature, pred_next_state_feature, pred_action = model(states, next_states, actions)

        # Compute the forward loss as the MSE loss between the real and predicted next state features.
        forward_loss = ((real_next_state_feature - pred_next_state_feature) ** 2).mean()
        # Compute the inverse loss as the MSE loss between the real and predicted actions.
        inverse_loss = ((actions - pred_action) ** 2).mean()

        # Combine the forward and inverse losses into a total loss.
        loss = forward_loss + inverse_loss

    # Return the total loss.
    return loss.item()

    **Overview**:
        Evaluation function for the ICM model.
    
chapter4_reward/curiosity_icm.py