(parser)
These options are passed to the construction of the model.
    Be careful with these as they will be used during translation.
These options are passed to the construction of the model.
    Be careful with these as they will be used during translation.
These options are passed to the construction of the model . Be careful with these as they will be used during translation .
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_argument('-src_word_vec_size', type=int, default=500,
                       help='Word embedding size for src.')
    group.add_argument('-tgt_word_vec_size', type=int, default=500,
                       help='Word embedding size for tgt.')
    group.add_argument('-word_vec_size', type=int, default=-1,
                       help='Word embedding size for src and tgt.')

    group.add_argument('-share_decoder_embeddings', action='store_true',
                       help="""Use a shared weight matrix for the input and
                       output word  embeddings in the decoder.""")
    group.add_argument('-share_embeddings', action='store_true',
                       help="""Share the word embeddings between encoder
                       and decoder. Need to use shared dictionary for this
                       option.""")
    group.add_argument('-position_encoding', action='store_true',
                       help="""Use a sin to mark relative words positions.
                       Necessary for non-RNN style models.
                       """)

    group = parser.add_argument_group('Model-Embedding Features')
    group.add_argument('-feat_merge', type=str, default='concat',
                       choices=['concat', 'sum', 'mlp'],
                       help="""Merge action for incorporating features embeddings.
                       Options [concat|sum|mlp].""")
    group.add_argument('-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_argument('-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.""")

    # Encoder-Decoder Options
    group = parser.add_argument_group('Model- Encoder-Decoder')
    group.add_argument('-model_type', default='text',
                       help="""Type of source model to use. Allows
                       the system to incorporate non-text inputs.
                       Options are [text|img|audio].""")

    group.add_argument('-encoder_type', type=str, default='rnn',
                       choices=['rnn', 'brnn', 'mean', 'transformer', 'cnn'],
                       help="""Type of encoder layer to use. Non-RNN layers
                       are experimental. Options are
                       [rnn|brnn|mean|transformer|cnn].""")
    group.add_argument('-decoder_type', type=str, default='rnn',
                       choices=['rnn', 'transformer', 'cnn'],
                       help="""Type of decoder layer to use. Non-RNN layers
                       are experimental. Options are
                       [rnn|transformer|cnn].""")

    group.add_argument('-layers', type=int, default=-1,
                       help='Number of layers in enc/dec.')
    group.add_argument('-enc_layers', type=int, default=2,
                       help='Number of layers in the encoder')
    group.add_argument('-dec_layers', type=int, default=2,
                       help='Number of layers in the decoder')
    group.add_argument('-rnn_size', type=int, default=500,
                       help='Size of rnn hidden states')
    group.add_argument('-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_argument('-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_argument('-bridge', action="store_true",
                       help="""Have an additional layer between the last encoder
                       state and the first decoder state""")
    group.add_argument('-rnn_type', type=str, default='LSTM',
                       choices=['LSTM', 'GRU', 'SRU'],
                       action=CheckSRU,
                       help="""The gate type to use in the RNNs""")
    # group.add_argument('-residual',   action="store_true",
    #                     help="Add residual connections between RNN layers.")

    group.add_argument('-brnn', action=DeprecateAction,
                       help="Deprecated, use `encoder_type`.")

    group.add_argument('-context_gate', type=str, default=None,
                       choices=['source', 'target', 'both'],
                       help="""Type of context gate to use.
                       Do not select for no context gate.""")

    # Attention options
    group = parser.add_argument_group('Model- Attention')
    group.add_argument('-global_attention', type=str, default='general',
                       choices=['dot', 'general', 'mlp'],
                       help="""The attention type to use:
                       dotprod or general (Luong) or MLP (Bahdanau)""")
    group.add_argument('-global_attention_function', type=str,
                       default="softmax", choices=["softmax", "sparsemax"])
    group.add_argument('-self_attn_type', type=str, default="scaled-dot",
                       help="""Self attention type in Transformer decoder
                       layer -- currently "scaled-dot" or "average" """)
    group.add_argument('-heads', type=int, default=8,
                       help='Number of heads for transformer self-attention')
    group.add_argument('-transformer_ff', type=int, default=2048,
                       help='Size of hidden transformer feed-forward')

    # Generator and loss options.
    group.add_argument('-copy_attn', action="store_true",
                       help='Train copy attention layer.')
    group.add_argument('-generator_function', default="log_softmax",
                       choices=["log_softmax", "sparsemax"],
                       help="""Which function to use for generating
                       probabilities over the target vocabulary (choices:
                       log_softmax, sparsemax)""")
    group.add_argument('-copy_attn_force', action="store_true",
                       help='When available, train to copy.')
    group.add_argument('-reuse_copy_attn', action="store_true",
                       help="Reuse standard attention for copy")
    group.add_argument('-copy_loss_by_seqlength', action="store_true",
                       help="Divide copy loss by length of sequence")
    group.add_argument('-coverage_attn', action="store_true",
                       help='Train a coverage attention layer.')
    group.add_argument('-lambda_coverage', type=float, default=1,
                       help='Lambda value for coverage.')
def model_opts ( parser ) : # Embedding Options group = parser . add_argument_group ( 'Model-Embeddings' ) group . add_argument ( '-src_word_vec_size' , type = int , default = 500 , help = 'Word embedding size for src.' ) group . add_argument ( '-tgt_word_vec_size' , type = int , default = 500 , help = 'Word embedding size for tgt.' ) group . add_argument ( '-word_vec_size' , type = int , default = - 1 , help = 'Word embedding size for src and tgt.' ) group . add_argument ( '-share_decoder_embeddings' , action = 'store_true' , help = """Use a shared weight matrix for the input and
                       output word  embeddings in the decoder.""" ) group . add_argument ( '-share_embeddings' , action = 'store_true' , help = """Share the word embeddings between encoder
                       and decoder. Need to use shared dictionary for this
                       option.""" ) group . add_argument ( '-position_encoding' , action = 'store_true' , help = """Use a sin to mark relative words positions.
                       Necessary for non-RNN style models.
                       """ ) group = parser . add_argument_group ( 'Model-Embedding Features' ) group . add_argument ( '-feat_merge' , type = str , default = 'concat' , choices = [ 'concat' , 'sum' , 'mlp' ] , help = """Merge action for incorporating features embeddings.
                       Options [concat|sum|mlp].""" ) group . add_argument ( '-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_argument ( '-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.""" ) # Encoder-Decoder Options group = parser . add_argument_group ( 'Model- Encoder-Decoder' ) group . add_argument ( '-model_type' , default = 'text' , help = """Type of source model to use. Allows
                       the system to incorporate non-text inputs.
                       Options are [text|img|audio].""" ) group . add_argument ( '-encoder_type' , type = str , default = 'rnn' , choices = [ 'rnn' , 'brnn' , 'mean' , 'transformer' , 'cnn' ] , help = """Type of encoder layer to use. Non-RNN layers
                       are experimental. Options are
                       [rnn|brnn|mean|transformer|cnn].""" ) group . add_argument ( '-decoder_type' , type = str , default = 'rnn' , choices = [ 'rnn' , 'transformer' , 'cnn' ] , help = """Type of decoder layer to use. Non-RNN layers
                       are experimental. Options are
                       [rnn|transformer|cnn].""" ) group . add_argument ( '-layers' , type = int , default = - 1 , help = 'Number of layers in enc/dec.' ) group . add_argument ( '-enc_layers' , type = int , default = 2 , help = 'Number of layers in the encoder' ) group . add_argument ( '-dec_layers' , type = int , default = 2 , help = 'Number of layers in the decoder' ) group . add_argument ( '-rnn_size' , type = int , default = 500 , help = 'Size of rnn hidden states' ) group . add_argument ( '-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_argument ( '-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_argument ( '-bridge' , action = "store_true" , help = """Have an additional layer between the last encoder
                       state and the first decoder state""" ) group . add_argument ( '-rnn_type' , type = str , default = 'LSTM' , choices = [ 'LSTM' , 'GRU' , 'SRU' ] , action = CheckSRU , help = """The gate type to use in the RNNs""" ) # group.add_argument('-residual',   action="store_true", #                     help="Add residual connections between RNN layers.") group . add_argument ( '-brnn' , action = DeprecateAction , help = "Deprecated, use `encoder_type`." ) group . add_argument ( '-context_gate' , type = str , default = None , choices = [ 'source' , 'target' , 'both' ] , help = """Type of context gate to use.
                       Do not select for no context gate.""" ) # Attention options group = parser . add_argument_group ( 'Model- Attention' ) group . add_argument ( '-global_attention' , type = str , default = 'general' , choices = [ 'dot' , 'general' , 'mlp' ] , help = """The attention type to use:
                       dotprod or general (Luong) or MLP (Bahdanau)""" ) group . add_argument ( '-global_attention_function' , type = str , default = "softmax" , choices = [ "softmax" , "sparsemax" ] ) group . add_argument ( '-self_attn_type' , type = str , default = "scaled-dot" , help = """Self attention type in Transformer decoder
                       layer -- currently "scaled-dot" or "average" """ ) group . add_argument ( '-heads' , type = int , default = 8 , help = 'Number of heads for transformer self-attention' ) group . add_argument ( '-transformer_ff' , type = int , default = 2048 , help = 'Size of hidden transformer feed-forward' ) # Generator and loss options. group . add_argument ( '-copy_attn' , action = "store_true" , help = 'Train copy attention layer.' ) group . add_argument ( '-generator_function' , default = "log_softmax" , choices = [ "log_softmax" , "sparsemax" ] , help = """Which function to use for generating
                       probabilities over the target vocabulary (choices:
                       log_softmax, sparsemax)""" ) group . add_argument ( '-copy_attn_force' , action = "store_true" , help = 'When available, train to copy.' ) group . add_argument ( '-reuse_copy_attn' , action = "store_true" , help = "Reuse standard attention for copy" ) group . add_argument ( '-copy_loss_by_seqlength' , action = "store_true" , help = "Divide copy loss by length of sequence" ) group . add_argument ( '-coverage_attn' , action = "store_true" , help = 'Train a coverage attention layer.' ) group . add_argument ( '-lambda_coverage' , type = float , default = 1 , help = 'Lambda value for coverage.' )