Repository: flairNLP/flair

Issue:
I want to set RNN type in initializing SequenceTagger 
To be removed, once it is done: Please add the appropriate label to this ticket, e.g. feature or enhancement.

**Is your feature/enhancement request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

I want to change SequenceTagger in initializing SequenceTagger. 

**Describe the solution you'd like**
Please provide suggestions on how to solve the problem, how to implement the idea.

* add default setting of instance variables on __init__ method

for example, 

```python

class SequenceTagger(flair.nn.Model):
    def __init__(
        self,
        hidden_size: int,
        embeddings: TokenEmbeddings,
        tag_dictionary: Dictionary,
        tag_type: str,
        use_crf: bool = True,
        use_rnn: bool = True,
        rnn_layers: int = 1,
        dropout: float = 0.0,
        word_dropout: float = 0.05,
        locked_dropout: float = 0.5,
        train_initial_hidden_state: bool = False,
        pickle_module: str = "pickle",
        relearn_embeddings: bool = True,
        bidirectional: bool = True, 
        rnn_type: str = 'LSTM'
    ):
        """
        Initializes a SequenceTagger
        :param hidden_size: number of hidden states in RNN
        :param embeddings: word embeddings used in tagger
        :param tag_dictionary: dictionary of tags you want to predict
        :param tag_type: string identifier for tag type
        :param use_crf: if True use CRF decoder, else project directly to tag space
        :param use_rnn: if True use RNN layer, otherwise use word embeddings directly
        :param rnn_layers: number of RNN layers
        :param dropout: dropout probability
        :param word_dropout: word dropout probability
        :param locked_dropout: locked dropout probability
        :param train_initial_hidden_state: if True, trains initial hidden state of RNN
        """

        super(SequenceTagger, self).__init__()
        if rnn_type not in ['LSTM', 'GRU']: 
            raise ValueError('RNN type must be LSTM or GRU.')
```


**Additional context**
Add any other context or screenshots about the feature/enhancement request.



Discussion:

Resolving patch:
diff --git a/flair/models/sequence_tagger_model.py b/flair/models/sequence_tagger_model.py
--- a/flair/models/sequence_tagger_model.py
+++ b/flair/models/sequence_tagger_model.py
@@ -78,6 +78,7 @@ def __init__(
         word_dropout: float = 0.05,
         locked_dropout: float = 0.5,
         train_initial_hidden_state: bool = False,
+        rnn_type: str = "LSTM",
         pickle_module: str = "pickle",
     ):
         """
@@ -140,7 +141,7 @@ def __init__(
 
         self.train_initial_hidden_state = train_initial_hidden_state
         self.bidirectional = True
-        self.rnn_type = "LSTM"
+        self.rnn_type = rnn_type
 
         # bidirectional LSTM on top of embedding layer
         if self.use_rnn:
@@ -211,11 +212,13 @@ def _get_state_dict(self):
             "rnn_layers": self.rnn_layers,
             "use_word_dropout": self.use_word_dropout,
             "use_locked_dropout": self.use_locked_dropout,
+            "rnn_type": self.rnn_type,
         }
         return model_state
 
     def _init_model_with_state_dict(state):
 
+        rnn_type = "LSTM" if not "rnn_type" in state.keys() else state["rnn_type"]
         use_dropout = 0.0 if not "use_dropout" in state.keys() else state["use_dropout"]
         use_word_dropout = (
             0.0 if not "use_word_dropout" in state.keys() else state["use_word_dropout"]
@@ -243,6 +246,7 @@ def _init_model_with_state_dict(state):
             word_dropout=use_word_dropout,
             locked_dropout=use_locked_dropout,
             train_initial_hidden_state=train_initial_hidden_state,
+            rnn_type=rnn_type,
         )
         model.load_state_dict(state["state_dict"])
         return model


Test patch: