This is the code: import torch
import torch.optim as optim
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader
from sklearn.model_selection import train_test_split

# Assuming you have already defined your MoE model, DataLoader, and loss function
from moe import MOELayer
from data_preprocessing import DataPreprocessor

def advanced_dynamic_expert_allocation(validation_losses, num_experts):
    """
    Computes dynamic expert allocation based on validation losses.

    Args:
        validation_losses (list): List of validation losses for each expert.
        num_experts (int): Number of experts.

    Returns:
        torch.Tensor: Expert weights (probabilities) for each expert.
    """
    # Compute inverse validation losses (lower loss -> higher weight)
    inverse_losses = [1.0 / loss for loss in validation_losses]

    # Normalize the inverse losses to get expert weights
    total_inverse_loss = sum(inverse_losses)
    expert_weights = torch.tensor([loss / total_inverse_loss for loss in inverse_losses])

    return expert_weights

def train_moe_model(x_train, y_train, x_val, y_val, moe_model, batch_size, num_epochs, lr, device, 
                      dynamic_expert_allocation=False, validation_losses=None, num_experts=None):
    moe_model.to(device)
    optimizer = optim.Adam(moe_model.parameters(), lr=lr)
    criterion = nn.CrossEntropyLoss()
    train_loader = DataLoader(x_train, y_train, batch_size=batch_size, shuffle=True)
    valid_loader = DataLoader(x_val, y_val, batch_size=batch_size, shuffle=False)

    for epoch in range(num_epochs):
        moe_model.train()
        total_loss = 0.0

        for batch in train_loader:
            inputs, targets = batch.text.to(device), batch.label.to(device)
            optimizer.zero_grad()

            # Forward pass
            outputs = moe_model(inputs)

            # Compute dynamic expert allocation
            gate_outputs = F.softmax(moe_model.gating_network(inputs), dim=1)
            expert_allocation = advanced_dynamic_expert_allocation(validation_losses, num_experts)

            # Apply expert weights to expert outputs
            weighted_outputs = torch.sum(expert_allocation.unsqueeze(2) * outputs, dim=1)

            # Compute loss
            loss = criterion(weighted_outputs, targets)

            # Backward pass and optimization
            loss.backward()
            optimizer.step()

            total_loss += loss.item()

        avg_train_loss = total_loss / len(train_loader)

        # Validation
        moe_model.eval()
        valid_loss = 0.0
        with torch.no_grad():
            for batch in valid_loader:
                inputs, targets = batch.text.to(device), batch.label.to(device)
                outputs = moe_model(inputs)
                valid_loss += criterion(outputs, targets).item()

        avg_valid_loss = valid_loss / len(valid_loader)

        print(f"Epoch {epoch+1}/{num_epochs} | Train Loss: {avg_train_loss:.4f} | Valid Loss: {avg_valid_loss:.4f}")

        # Save model checkpoint
        torch.save(moe_model.state_dict(), f"moe_model_epoch{epoch+1}.pth")

    print("Training completed. Model checkpoints saved.")

if __name__ == "__main__":
    preprocessor = DataPreprocessor(max_vocab_size=25000, embedding_dim=100)
    X_train, X_test, y_train, y_test = preprocessor.load_data()
    X_val, X_test, y_val, y_test = train_test_split(X_test, y_test, test_size=0.5, random_state=42)
    batch_size = 32
    num_epochs = 10
    learning_rate = 0.001
    num_experts = 2
    device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

    # Initialize your MoE model
    input_size = 300  # Example: word embedding size
    hidden_size = 128
    output_size = 200  # Example: binary classification (adjust based on your task)
    moe_model = MOELayer(input_size, num_experts, hidden_size, output_size)

    train_moe_model(X_train, y_train, X_val, y_val, moe_model, batch_size, num_epochs, learning_rate, device)   and this is the error: Traceback (most recent call last):
  File "c:\Users\L14\Documents\Projets\Project-Hajax\train.py", line 103, in <module>
    train_moe_model(X_train, y_train, X_val, y_val, moe_model, batch_size, num_epochs, learning_rate, device)
  File "c:\Users\L14\Documents\Projets\Project-Hajax\train.py", line 37, in train_moe_model
    train_loader = DataLoader(x_train, y_train, batch_size=batch_size, shuffle=True)
TypeError: DataLoader.__init__() got multiple values for argument 'batch_size'