code: def recommend_hyperparameters(df, model=None):
      """
      Makes recommendations on the batch_size to use for training, based on the dataset size
  
      """
      potential_batch_sizes = [2, 4, 8, 12, 16, 32, 64, 128]
  
      max_bs = 128
      if len(df) < 128:
          max_bs = 2
          for potential_bs in potential_batch_sizes:
              if potential_bs < len(df) * 0.9:
                  max_bs = potential_bs
  
      bs = min(max_bs, 32)
  
      df_char_length = df.apply(
          lambda x: len(x.prompt) + len(x.completion), axis=1
      )
      length_by_chars = sorted(list(df_char_length))
      n_samples_under_99p5_limit = math.ceil(
          len(df_char_length) * 0.995
      )
      char_length_99p5 = length_by_chars[n_samples_under_99p5_limit - 1]
      mean_char_length = np.mean(length_by_chars)
      std_char_length = np.std(length_by_chars)
  
      # filter out only outliers that are >2 std above mean
      max_char_length = max(
          min(
              mean_char_length + 2 * std_char_length,
              length_by_chars[-1],
          ),
          char_length_99p5,
      )
  
      # every token is around 4 chars + 100 for extra capacity
      max_seq_length = max_char_length // 4 + 100
  
      if len(df) <= 100:
          encoder_hidden_size = 1024
      elif len(df) <= 1000:
          encoder_hidden_size = 2048
      else:
          encoder_hidden_size = 4096
  
      if len(df) <= 100:
          lr = 5e-3
      elif len(df) <= 1000:
          lr = 1e-3
      elif len(df) <= 10000:
          lr = 5e-4
      else:
          lr = 1e-4
  
      return {
          "batch_size": bs,
          "max_batch_size": max_bs,
          "num_virtual_tokens": 10,
          "lr": lr,
          "epochs": 10,
          "max_seq_length": max_seq_length,
          "encoder_hidden_size": encoder_hidden_size,
      }
  
imports: import argparse
  import math
  import os
  import pathlib
  from collections import Counter
  import numpy
  import pandas
label_desc: Use image node_id 3 for calling a global function with example usage: recommend_hyperparameters(df, model) and returns: dict