code: def model_opts(parser):
      """
      These options are passed to the construction of the model.
      Be careful with these as they will be used during translation.
      """
  
      # Embedding Options
      group = parser.add_argument_group("Model-Embeddings")
      group.add(
          "--src_word_vec_size",
          "-src_word_vec_size",
          type=int,
          default=500,
          help="Word embedding size for src.",
      )
      group.add(
          "--tgt_word_vec_size",
          "-tgt_word_vec_size",
          type=int,
          default=500,
          help="Word embedding size for tgt.",
      )
      group.add(
          "--word_vec_size",
          "-word_vec_size",
          type=int,
          default=-1,
          help="Word embedding size for src and tgt.",
      )
  
      group.add(
          "--share_decoder_embeddings",
          "-share_decoder_embeddings",
          action="store_true",
          help="Use a shared weight matrix for the input and "
          "output word  embeddings in the decoder.",
      )
      group.add(
          "--share_embeddings",
          "-share_embeddings",
          action="store_true",
          help="Share the word embeddings between encoder "
          "and decoder. Need to use shared dictionary for this "
          "option.",
      )
      group.add(
          "--position_encoding",
          "-position_encoding",
          action="store_true",
          help="Use a sin to mark relative words positions. "
          "Necessary for non-RNN style models.",
      )
      group.add(
          "--position_encoding_type",
          "-position_encoding_type",
          type=str,
          default="SinusoidalInterleaved",
          choices=["SinusoidalInterleaved", "SinusoidalConcat"],
          help="Type of positional encoding. At the moment: "
          "Sinusoidal fixed, Interleaved or Concat",
      )
  
      group.add(
          "-update_vocab",
          "--update_vocab",
          action="store_true",
          help="Update source and target existing vocabularies",
      )
  
      group = parser.add_argument_group("Model-Embedding Features")
      group.add(
          "--feat_merge",
          "-feat_merge",
          type=str,
          default="concat",
          choices=["concat", "sum", "mlp"],
          help="Merge action for incorporating features embeddings. "
          "Options [concat|sum|mlp].",
      )
      group.add(
          "--feat_vec_size",
          "-feat_vec_size",
          type=int,
          default=-1,
          help="If specified, feature embedding sizes "
          "will be set to this. Otherwise, feat_vec_exponent "
          "will be used.",
      )
      group.add(
          "--feat_vec_exponent",
          "-feat_vec_exponent",
          type=float,
          default=0.7,
          help="If -feat_merge_size is not set, feature "
          "embedding sizes will be set to N^feat_vec_exponent "
          "where N is the number of values the feature takes.",
      )
  
      # Model Task Options
      group = parser.add_argument_group("Model- Task")
      group.add(
          "-model_task",
          "--model_task",
          default=ModelTask.SEQ2SEQ,
          choices=[ModelTask.SEQ2SEQ, ModelTask.LANGUAGE_MODEL],
          help="Type of task for the model either seq2seq or lm",
      )
  
      # Encoder-Decoder Options
      group = parser.add_argument_group("Model- Encoder-Decoder")
      group.add(
          "--model_type",
          "-model_type",
          default="text",
          choices=["text"],
          help="Type of source model to use. Allows "
          "the system to incorporate non-text inputs. "
          "Options are [text].",
      )
      group.add(
          "--model_dtype",
          "-model_dtype",
          default="fp32",
          choices=["fp32", "fp16"],
          help="Data type of the model.",
      )
  
      group.add(
          "--encoder_type",
          "-encoder_type",
          type=str,
          default="rnn",
          help="Type of encoder layer to use. Non-RNN layers "
          "are experimental. Default options are "
          "[rnn|brnn|ggnn|mean|transformer|cnn|transformer_lm].",
      )
      group.add(
          "--decoder_type",
          "-decoder_type",
          type=str,
          default="rnn",
          help="Type of decoder layer to use. Non-RNN layers "
          "are experimental. Default options are "
          "[rnn|transformer|cnn|transformer].",
      )
  
      # Freeze Encoder and/or Decoder
      group.add(
          "--freeze_encoder",
          "-freeze_encoder",
          action="store_true",
          help="Freeze parameters in encoder.",
      )
      group.add(
          "--freeze_decoder",
          "-freeze_decoder",
          action="store_true",
          help="Freeze parameters in decoder.",
      )
  
      group.add(
          "--layers",
          "-layers",
          type=int,
          default=-1,
          help="Number of layers in enc/dec.",
      )
      group.add(
          "--enc_layers",
          "-enc_layers",
          type=int,
          default=2,
          help="Number of layers in the encoder",
      )
      group.add(
          "--dec_layers",
          "-dec_layers",
          type=int,
          default=2,
          help="Number of layers in the decoder",
      )
      group.add(
          "--hidden_size",
          "-hidden_size",
          type=int,
          default=-1,
          help="Size of rnn hidden states. Overwrites "
          "enc_hid_size and dec_hid_size",
      )
      group.add(
          "--enc_hid_size",
          "-enc_hid_size",
          type=int,
          default=500,
          help="Size of encoder rnn hidden states.",
      )
      group.add(
          "--dec_hid_size",
          "-dec_hid_size",
          type=int,
          default=500,
          help="Size of decoder rnn hidden states.",
      )
      group.add(
          "--cnn_kernel_width",
          "-cnn_kernel_width",
          type=int,
          default=3,
          help="Size of windows in the cnn, the kernel_size is "
          "(cnn_kernel_width, 1) in conv layer",
      )
  
      group.add(
          "--layer_norm",
          "-layer_norm",
          type=str,
          default="standard",
          choices=["standard", "rms"],
          help="The type of layer"
          " normalization in the transformer architecture. Choices are"
          " standard or rms. Default to standard",
      )
      group.add(
          "--norm_eps",
          "-norm_eps",
          type=float,
          default=1e-6,
          help="Layer norm epsilon",
      )
  
      group.add(
          "--pos_ffn_activation_fn",
          "-pos_ffn_activation_fn",
          type=str,
          default=ActivationFunction.relu,
          choices=ACTIVATION_FUNCTIONS.keys(),
          help="The activation"
          " function to use in PositionwiseFeedForward layer. Choices are"
          f" {ACTIVATION_FUNCTIONS.keys()}. Default to"
          f" {ActivationFunction.relu}.",
      )
  
      group.add(
          "--input_feed",
          "-input_feed",
          type=int,
          default=1,
          help="Feed the context vector at each time step as "
          "additional input (via concatenation with the word "
          "embeddings) to the decoder.",
      )
      group.add(
          "--bridge",
          "-bridge",
          action="store_true",
          help="Have an additional layer between the last encoder "
          "state and the first decoder state",
      )
      group.add(
          "--rnn_type",
          "-rnn_type",
          type=str,
          default="LSTM",
          choices=["LSTM", "GRU", "SRU"],
          action=CheckSRU,
          help="The gate type to use in the RNNs",
      )
      group.add(
          "--context_gate",
          "-context_gate",
          type=str,
          default=None,
          choices=["source", "target", "both"],
          help="Type of context gate to use. "
          "Do not select for no context gate.",
      )
  
      # The following options (bridge_extra_node to n_steps) are used
      # for training with --encoder_type ggnn (Gated Graph Neural Network).
      group.add(
          "--bridge_extra_node",
          "-bridge_extra_node",
          type=bool,
          default=True,
          help="Graph encoder bridges only extra node to decoder as input",
      )
      group.add(
          "--bidir_edges",
          "-bidir_edges",
          type=bool,
          default=True,
          help="Graph encoder autogenerates bidirectional edges",
      )
      group.add(
          "--state_dim",
          "-state_dim",
          type=int,
          default=512,
          help="Number of state dimensions in the graph encoder",
      )
      group.add(
          "--n_edge_types",
          "-n_edge_types",
          type=int,
          default=2,
          help="Number of edge types in the graph encoder",
      )
      group.add(
          "--n_node",
          "-n_node",
          type=int,
          default=2,
          help="Number of nodes in the graph encoder",
      )
      group.add(
          "--n_steps",
          "-n_steps",
          type=int,
          default=2,
          help="Number of steps to advance graph encoder",
      )
      group.add(
          "--src_ggnn_size",
          "-src_ggnn_size",
          type=int,
          default=0,
          help="Vocab size plus feature space for embedding input",
      )
  
      # Attention options
      group = parser.add_argument_group("Model- Attention")
      group.add(
          "--global_attention",
          "-global_attention",
          type=str,
          default="general",
          choices=["dot", "general", "mlp", "none"],
          help="The attention type to use: "
          "dotprod or general (Luong) or MLP (Bahdanau)",
      )
      group.add(
          "--global_attention_function",
          "-global_attention_function",
          type=str,
          default="softmax",
          choices=["softmax", "sparsemax"],
      )
      group.add(
          "--self_attn_type",
          "-self_attn_type",
          type=str,
          default="scaled-dot-flash",
          help="Self attention type in Transformer decoder "
          'layer -- currently "scaled-dot", "scaled-dot-flash" or "average" ',
      )
      group.add(
          "--max_relative_positions",
          "-max_relative_positions",
          type=int,
          default=0,
          help="This setting enable relative position encoding"
          "We support two types of encodings:"
          "set this -1 to enable Rotary Embeddings"
          "more info: https://arxiv.org/abs/2104.09864"
          "set this to > 0 (ex: 16, 32) to use"
          "Maximum distance between inputs in relative "
          "positions representations. "
          "more info: https://arxiv.org/pdf/1803.02155.pdf",
      )
      group.add(
          "--relative_positions_buckets",
          "-relative_positions_buckets",
          type=int,
          default=0,
          help="This setting enable relative position bias"
          "more info: https://github.com/google-research/text-to-text-transfer-transformer",
      )
      group.add(
          "--rotary_interleave",
          "-rotary_interleave",
          type=bool,
          default=True,
          help="Interleave the head dimensions when rotary"
          " embeddings are applied."
          "    Otherwise the head dimensions are sliced in half."
          "True = default Llama from Meta (original)"
          "False = used by all Hugging face models",
      )
      group.add(
          "--rotary_theta",
          "-rotary_theta",
          type=int,
          default=10000,
          help="Rotary theta base length"
          "1e4 for Llama2.Mistral"
          "1e6 for Mixtral",
      )
      group.add(
          "--rotary_dim",
          "-rotary_dim",
          type=int,
          default=0,
          help="Rotary dim when model requires it to be different to head dim",
      )
      group.add(
          "--heads",
          "-heads",
          type=int,
          default=8,
          help="Number of heads for transformer self-attention",
      )
      group.add(
          "--sliding_window",
          "-sliding_window",
          type=int,
          default=0,
          help="sliding window for transformer self-attention",
      )
      group.add(
          "--transformer_ff",
          "-transformer_ff",
          type=int,
          default=2048,
          help="Size of hidden transformer feed-forward",
      )
      group.add(
          "--num_experts",
          "-num_experts",
          type=int,
          default=0,
          help="Number of experts",
      )
      group.add(
          "--num_experts_per_tok",
          "-num_experts_per_tok",
          type=int,
          default=2,
          help="Number of experts per token",
      )
      group.add(
          "--aan_useffn",
          "-aan_useffn",
          action="store_true",
          help="Turn on the FFN layer in the AAN decoder",
      )
      group.add(
          "--add_qkvbias",
          "-add_qkvbias",
          action="store_true",
          help="Add bias to nn.linear of Query/Key/Value in MHA"
          "Note: this will add bias to output proj layer too",
      )
      group.add(
          "--multiquery",
          "-multiquery",
          action="store_true",
          help="Use MultiQuery attention"
          "Note: https://arxiv.org/pdf/1911.02150.pdf",
      )
      group.add(
          "--num_kv",
          "-num_kv",
          type=int,
          default=0,
          help="Number of heads for KV in the variant of MultiQuery attention (egs: Falcon 40B)",
      )
      group.add(
          "--add_ffnbias",
          "-add_ffnbias",
          action="store_true",
          help="Add bias to nn.linear of Position_wise FFN",
      )
      group.add(
          "--parallel_residual",
          "-parallel_residual",
          action="store_true",
          help="Use Parallel residual in Decoder Layer"
          "Note: this is used by GPT-J / Falcon Architecture",
      )
      group.add(
          "--shared_layer_norm",
          "-shared_layer_norm",
          action="store_true",
          help="Use a shared layer_norm in parallel residual attention"
          "Note: must be true for Falcon 7B / false for Falcon 40B"
          "same for GPT-J and GPT-NeoX models",
      )
      # Alignement options
      group = parser.add_argument_group("Model - Alignement")
      group.add(
          "--lambda_align",
          "-lambda_align",
          type=float,
          default=0.0,
          help="Lambda value for alignement loss of Garg et al (2019)"
          "For more detailed information, see: "
          "https://arxiv.org/abs/1909.02074",
      )
      group.add(
          "--alignment_layer",
          "-alignment_layer",
          type=int,
          default=-3,
          help="Layer number which has to be supervised.",
      )
      group.add(
          "--alignment_heads",
          "-alignment_heads",
          type=int,
          default=0,
          help="N. of cross attention heads per layer to supervised with",
      )
      group.add(
          "--full_context_alignment",
          "-full_context_alignment",
          action="store_true",
          help="Whether alignment is conditioned on full target context.",
      )
  
      # Generator and loss options.
      group = parser.add_argument_group("Generator")
      group.add(
          "--copy_attn",
          "-copy_attn",
          action="store_true",
          help="Train copy attention layer.",
      )
      group.add(
          "--copy_attn_type",
          "-copy_attn_type",
          type=str,
          default=None,
          choices=["dot", "general", "mlp", "none"],
          help="The copy attention type to use. Leave as None to use "
          "the same as -global_attention.",
      )
      group.add(
          "--generator_function",
          "-generator_function",
          default="softmax",
          choices=["softmax", "sparsemax"],
          help="Which function to use for generating "
          "probabilities over the target vocabulary (choices: "
          "softmax, sparsemax)",
      )
      group.add(
          "--copy_attn_force",
          "-copy_attn_force",
          action="store_true",
          help="When available, train to copy.",
      )
      group.add(
          "--reuse_copy_attn",
          "-reuse_copy_attn",
          action="store_true",
          help="Reuse standard attention for copy",
      )
      group.add(
          "--copy_loss_by_seqlength",
          "-copy_loss_by_seqlength",
          action="store_true",
          help="Divide copy loss by length of sequence",
      )
      group.add(
          "--coverage_attn",
          "-coverage_attn",
          action="store_true",
          help="Train a coverage attention layer.",
      )
      group.add(
          "--lambda_coverage",
          "-lambda_coverage",
          type=float,
          default=0.0,
          help="Lambda value for coverage loss of See et al (2017)",
      )
      group.add(
          "--lm_prior_model",
          "-lm_prior_model",
          type=str,
          default=None,
          help="LM model to used to train the TM",
      )
      group.add(
          "--lm_prior_lambda",
          "-lambda_prior_lambda",
          type=float,
          default=0.0,
          help="LM Prior Lambda",
      )
      group.add(
          "--lm_prior_tau",
          "-lambda_prior_tau",
          type=float,
          default=1.0,
          help="LM Prior Tau",
      )
      group.add(
          "--loss_scale",
          "-loss_scale",
          type=float,
          default=0,
          help="For FP16 training, the static loss scale to use. If not "
          "set, the loss scale is dynamically computed.",
      )
      group.add(
          "--apex_opt_level",
          "-apex_opt_level",
          type=str,
          default="",
          choices=["", "O0", "O1", "O2", "O3"],
          help="For FP16 training, the opt_level to use."
          "See https://nvidia.github.io/apex/amp.html#opt-levels.",
      )
      group.add(
          "--zero_out_prompt_loss",
          "-zero_out_prompt_loss",
          action="store_true",
          help="Set the prompt loss to zero."
          "Mostly for LLM finetuning."
          "Will be enabled only if the `insert_mask_before_placeholder` transform is applied",
      )
      group.add(
          "--use_ckpting",
          "-use_ckpting",
          default=[],
          nargs="+",
          choices=["ffn", "mha", "lora"],
          type=str,
          help="use gradient checkpointing those modules",
      )
  
imports: import configargparse
  from onmt.modules.sru import CheckSRU
  from onmt.transforms import AVAILABLE_TRANSFORMS
  from onmt.constants import ModelTask
  from onmt.modules.position_ffn import ACTIVATION_FUNCTIONS
  from onmt.modules.position_ffn import ActivationFunction
  from onmt.constants import DefaultTokens
label_desc: Use image node_id 10 for calling a global function with example usage: model_opts(parser) without return types