When def select_hyperparameters(num_tokens, compute_limits=None):
    """
    Selects hyperparameters for a MoE Transformer model using theoretical and empirical guidelines.

    Parameters:
    num_tokens (int): Number of tokens in the dataset.
    compute_limits (dict, optional): Constraints on computational resources such as memory and time.

    Returns:
    dict: Dictionary containing refined hyperparameters.
    """
    # Base hyperparameters, these can be adjusted based on dataset size and resources
    hyperparams = {
        'd_model': 512,
        'nhead': 8,
        'dim_feedforward': 2048,
        'num_encoder_layers': 6,
        'num_experts': 16,
        'dropout_rate': 0.1,
        'learning_rate': 3e-4,
        'batch_size': 64
    }

    # Adjust based on the number of tokens following research-based scaling laws
    if num_tokens < 1e5:  # Small dataset
        hyperparams['d_model'] = 256
        hyperparams['nhead'] = 4
        hyperparams['dim_feedforward'] = 1024
        hyperparams['num_encoder_layers'] = 4
        hyperparams['num_experts'] = 4
        hyperparams['batch_size'] = 32
    elif num_tokens < 1e7:  # Medium dataset
        # Keep the base hyperparameters
        pass
    else:  # Large dataset / scaling for future
        hyperparams['d_model'] = 1024
        hyperparams['nhead'] = 16
        hyperparams['dim_feedforward'] = 4096
        hyperparams['num_encoder_layers'] = 8
        hyperparams['num_experts'] = 32
        hyperparams['batch_size'] = 128

    # Gradient clipping heuristic based on depth
    hyperparams['gradient_clip_value'] = 1.0 / hyperparams['num_encoder_layers']

    # Dropout rate - adjust if larger models are needed, to counteract overfitting
    hyperparams['dropout_rate'] = 0.1 + hyperparams['d_model'] / 1024 * 0.05

    # Label smoothing - as per empirical studies
    hyperparams['label_smoothing'] = 0.1 if num_tokens > 1e6 else 0.0

    # Constraint-based adjustments
    if compute_limits:
        # Adjust for memory
        if compute_limits.get('memory'):
            memory_per_token = compute_limits['memory'] / float(num_tokens)
            if memory_per_token < 0.001:  # 1KB/token is arbitrary, adjust base on actual measurements
                hyperparams['d_model'] //= 2
                hyperparams['dim_feedforward'] //= 2

        # Adjust for time constraint
        if compute_limits.get('time'):
            # Faster convergence might be needed; increase learning rate
            # Decrease batch size to fit within the training time constraint
            hyperparams['learning_rate'] *= 1.5
            hyperparams['batch_size'] = max(16, hyperparams['batch_size'] // 2)

    return hyperparams

num_tokens = 258287

params = select_hyperparameters(num_tokens=num_tokens, compute_limits=True)
print("Parameters :\n", params)  is running i get this: Traceback (most recent call last):
  File "c:\Users\Dell-PC\Desktop\Projets\Mamba\Models_for_Datasets.py", line 72, in <module>
    params = select_hyperparameters(num_tokens=num_tokens, compute_limits=True)
  File "c:\Users\Dell-PC\Desktop\Projets\Mamba\Models_for_Datasets.py", line 55, in select_hyperparameters
    if compute_limits.get('memory'):
AttributeError: 'bool' object has no attribute 'get'