code: def get_optimal_params(cls, config):
      base_max_length = config.base_model.settings.get(
          "max_length", 512
      )
      base_n_epochs = config.base_model.settings.get("n_epochs", 8)
      base_batch_size = config.base_model.settings.get("batch_size", 2)
      base_learning_rate = config.base_model.settings.get("lr", 1e-5)
      if config.optimize_for.lower() == "speed":
          overrides = {
              "max_length": 128
              if config.chunk_long_sequences
              else base_max_length,
              "n_epochs": 5,
              "batch_size": 4,
              "chunk_context": 16,
              "predict_batch_size": 256
              if config.float_16_predict
              else 48,
              "mixed_precision": False,
              "float_16_predict": False,
              "lr": base_learning_rate,
          }
  
      elif config.optimize_for.lower() == "accuracy":
          overrides = {
              "max_length": base_max_length,
              "n_epochs": base_n_epochs,
              "batch_size": base_batch_size,
              "chunk_context": None,
              "predict_batch_size": 20,
              "mixed_precision": False,
              "float_16_predict": False,
              "lr": base_learning_rate,
          }
  
      elif config.optimize_for.lower() == "predict_speed":
          overrides = {
              "max_length": 128
              if config.chunk_long_sequences
              else base_max_length,
              "n_epochs": base_n_epochs,
              "batch_size": base_batch_size,
              "chunk_context": 16,
              "predict_batch_size": 256
              if config.float_16_predict
              else 48,
              "mixed_precision": False,
              "float_16_predict": False,
              "lr": base_learning_rate,
          }
      elif config.optimize_for.lower() == "accuracy_fp16":
          overrides = {
              "max_length": base_max_length,
              "n_epochs": base_n_epochs,
              "batch_size": 12,
              "chunk_context": None,
              "predict_batch_size": 40,
              "mixed_precision": True,
              "float_16_predict": True,
              "lr": base_learning_rate * 6,
          }
  
      elif config.optimize_for.lower() == "predict_speed_fp16":
          overrides = {
              "max_length": 128
              if config.chunk_long_sequences
              else base_max_length,
              "n_epochs": base_n_epochs,
              "batch_size": 64,
              "chunk_context": 16,
              "predict_batch_size": 256,
              "mixed_precision": True,
              "float_16_predict": True,
              "lr": base_learning_rate * 32,
          }
      else:
          raise ValueError(
              "Cannot optimise hyperparams for {}, must be either 'speed', 'predict_speed' or 'accuracy'".format(
                  config.optimize_for
              )
          )
      return overrides
  
imports: import os
  from urllib.parse import urljoin
  from finetune.base_models import SourceModel
  from finetune.base_models.bert.encoder import BERTEncoder, BERTEncoderMultuilingal, BERTEncoderLarge, DistilBERTEncoder, LayoutLMEncoder
  from finetune.base_models.bert.roberta_encoder import RoBERTaEncoder, RoBERTaEncoderV2, RoBERTaEncoderXDoc
  from finetune.base_models.bert.featurizer import bert_featurizer, layoutlm_featurizer, xdoc_featurizer, table_roberta_featurizer_twinbert
  from finetune.util.context_utils import get_context_layoutlm, get_context_doc_rep
  from finetune.util.download import BERT_BASE_URL, GPT2_BASE_URL, ROBERTA_BASE_URL, LAYOUTLM_BASE_URL, FINETUNE_BASE_FOLDER
  from finetune.util.featurizer_fusion import fused_featurizer
label_desc: Use image node_id 1 for calling the _BaseBert obj's underlying member method code with example usage: obj.get_optimal_params(cls, config) and returns: overrides