code: def base_lm_architecture(args):
      # backward compatibility for older model checkpoints
      if safe_hasattr(args, "no_tie_adaptive_proj"):
          # previous models defined --no-tie-adaptive-proj, so use the existence of
          # that option to determine if this is an "old" model checkpoint
          args.no_decoder_final_norm = (
              True  # old models always set this to True
          )
          if args.no_tie_adaptive_proj is False:
              args.tie_adaptive_proj = True
      if safe_hasattr(args, "decoder_final_norm"):
          args.no_decoder_final_norm = not args.decoder_final_norm
  
      args.dropout = safe_getattr(args, "dropout", 0.1)
      args.attention_dropout = safe_getattr(
          args, "attention_dropout", 0.0
      )
  
      args.decoder_embed_dim = safe_getattr(
          args, "decoder_embed_dim", 512
      )
      args.decoder_ffn_embed_dim = safe_getattr(
          args, "decoder_ffn_embed_dim", 2048
      )
      args.decoder_layers = safe_getattr(args, "decoder_layers", 6)
      args.decoder_attention_heads = safe_getattr(
          args, "decoder_attention_heads", 8
      )
      args.adaptive_softmax_cutoff = safe_getattr(
          args, "adaptive_softmax_cutoff", None
      )
      args.adaptive_softmax_dropout = safe_getattr(
          args, "adaptive_softmax_dropout", 0
      )
      args.adaptive_softmax_factor = safe_getattr(
          args, "adaptive_softmax_factor", 4
      )
      args.decoder_learned_pos = safe_getattr(
          args, "decoder_learned_pos", False
      )
      args.activation_fn = safe_getattr(args, "activation_fn", "relu")
  
      args.decoder_layerdrop = safe_getattr(
          args, "decoder_layerdrop", 0
      )
      args.decoder_layers_to_keep = safe_getattr(
          args, "decoder_layers_to_keep", None
      )
      args.quant_noise_pq = safe_getattr(args, "quant_noise_pq", 0)
      args.quant_noise_pq_block_size = safe_getattr(
          args, "quant_noise_pq_block_size", 8
      )
      args.quant_noise_scalar = safe_getattr(
          args, "quant_noise_scalar", 0
      )
  
      args.base_layers = safe_getattr(args, "base_layers", 0)
      args.base_sublayers = safe_getattr(args, "base_sublayers", 1)
      args.base_shuffle = safe_getattr(args, "base_shuffle", False)
  
      args.add_bos_token = safe_getattr(args, "add_bos_token", False)
      args.no_token_positional_embeddings = safe_getattr(
          args, "no_token_positional_embeddings", False
      )
      args.share_decoder_input_output_embed = safe_getattr(
          args, "share_decoder_input_output_embed", False
      )
      args.character_embeddings = safe_getattr(
          args, "character_embeddings", False
      )
  
      args.decoder_output_dim = safe_getattr(
          args, "decoder_output_dim", args.decoder_embed_dim
      )
      args.decoder_input_dim = safe_getattr(
          args, "decoder_input_dim", args.decoder_embed_dim
      )
  
      # Model training is not stable without this
      args.decoder_normalize_before = True
      args.no_decoder_final_norm = safe_getattr(
          args, "no_decoder_final_norm", False
      )
  
      args.adaptive_input = safe_getattr(args, "adaptive_input", False)
      args.adaptive_input_factor = safe_getattr(
          args, "adaptive_input_factor", 4
      )
      args.adaptive_input_cutoff = safe_getattr(
          args, "adaptive_input_cutoff", None
      )
  
      args.tie_adaptive_weights = safe_getattr(
          args, "tie_adaptive_weights", False
      )
      args.tie_adaptive_proj = safe_getattr(
          args, "tie_adaptive_proj", False
      )
  
      args.no_scale_embedding = safe_getattr(
          args, "no_scale_embedding", False
      )
      args.layernorm_embedding = safe_getattr(
          args, "layernorm_embedding", False
      )
      args.checkpoint_activations = safe_getattr(
          args, "checkpoint_activations", False
      )
      args.offload_activations = safe_getattr(
          args, "offload_activations", False
      )
      args.scale_fc = safe_getattr(args, "scale_fc", False)
      args.scale_attn = safe_getattr(args, "scale_attn", False)
      args.scale_heads = safe_getattr(args, "scale_heads", False)
      args.scale_resids = safe_getattr(args, "scale_resids", False)
      if args.offload_activations:
          args.checkpoint_activations = True
  
imports: from dataclasses import dataclass, field
  from typing import Optional
  from omegaconf import II
  from fairseq import options, utils
  from fairseq.dataclass import ChoiceEnum, FairseqDataclass
  from fairseq.models import FairseqLanguageModel, register_model, register_model_architecture
  from fairseq.models.transformer import DEFAULT_MIN_PARAMS_TO_WRAP, Embedding, TransformerDecoder
  from fairseq.modules import AdaptiveInput, CharacterTokenEmbedder
  from fairseq.utils import safe_getattr, safe_hasattr
label_desc: Use image node_id 1 for calling a global function with example usage: base_lm_architecture(args) without return types