class_docstr: For :class:`Registrable` we need to have a ``Type[Seq2SeqEncoder]`` as the value registered for each
  key.  What that means is that we need to be able to ``__call__`` these values (as is done with
  ``__init__`` on the class), and be able to call ``from_params()`` on the value.
  
  In order to accomplish this, we have two options: (1) we create a ``Seq2SeqEncoder`` class for
  all of pytorch's RNN modules individually, with our own parallel classes that we register in
  the registry; or (2) we wrap pytorch's RNNs with something that `mimics` the required
  API.  We've gone with the second option here.
  
  This is a two-step approach: first, we have the :class:`PytorchSeq2SeqWrapper` class that handles
  the interface between a pytorch RNN and our ``Seq2SeqEncoder`` API.  Our ``PytorchSeq2SeqWrapper``
  takes an instantiated pytorch RNN and just does some interface changes.  Second, we need a way
  to create one of these ``PytorchSeq2SeqWrappers``, with an instantiated pytorch RNN, from the
  registry.  That's what this ``_Wrapper`` does.  The only thing this class does is instantiate
  the pytorch RNN in a way that's compatible with ``Registrable``, then pass it off to the
  ``PytorchSeq2SeqWrapper`` class.
  
  When you instantiate a ``_Wrapper`` object, you give it an ``RNNBase`` subclass, which we save
  to ``self``.  Then when called (as if we were instantiating an actual encoder with
  ``Encoder(**params)``, or with ``Encoder.from_params(params)``), we pass those parameters
  through to the ``RNNBase`` constructor, then pass the instantiated pytorch RNN to the
  ``PytorchSeq2SeqWrapper``.  This lets us use this class in the registry and have everything just
  work.
class_docstr_tok: ["For",":","class",":","`","Registrable","`","we","need","to","have","a","``","Type","[","Seq2SeqEncoder","]","``","as","the","value","registered","for","each","key",".","What","that","means","is","that","we","need","to","be","able","to","``","__call__","``","these","values","(","as","is","done","with","``","__init__","``","on","the","class",")",",","and","be","able","to","call","``","from_params","(",")","``","on","the","value",".","In","order","to","accomplish","this",",","we","have","two","options",":","(","1",")","we","create","a","``","Seq2SeqEncoder","``","class","for","all","of","pytorch","'s","RNN","modules","individually",",","with","our","own","parallel","classes","that","we","register","in","the","registry",";","or","(","2",")","we","wrap","pytorch","'s","RNNs","with","something","that","`","mimics","`","the","required","API",".","We","'ve","gone","with","the","second","option","here",".","This","is","a","two-step","approach",":","first",",","we","have","the",":","class",":","`","PytorchSeq2SeqWrapper","`","class","that","handles","the","interface","between","a","pytorch","RNN","and","our","``","Seq2SeqEncoder","``","API",".","Our","``","PytorchSeq2SeqWrapper","``","takes","an","instantiated","pytorch","RNN","and","just","does","some","interface","changes",".","Second",",","we","need","a","way","to","create","one","of","these","``","PytorchSeq2SeqWrappers","``",",","with","an","instantiated","pytorch","RNN",",","from","the","registry",".","That","'s","what","this","``","_Wrapper","``","does",".","The","only","thing","this","class","does","is","instantiate","the","pytorch","RNN","in","a","way","that","'s","compatible","with","``","Registrable","``",",","then","pass","it","off","to","the","``","PytorchSeq2SeqWrapper","``","class",".","When","you","instantiate","a","``","_Wrapper","``","object",",","you","give","it","an","``","RNNBase","``","subclass",",","which","we","save","to","``","self","``",".","Then","when","called","(","as","if","we","were","instantiating","an","actual","encoder","with","``","Encoder","(","*","*","params",")","``",",","or","with","``","Encoder.from_params","(","params",")","``",")",",","we","pass","those","parameters","through","to","the","``","RNNBase","``","constructor",",","then","pass","the","instantiated","pytorch","RNN","to","the","``","PytorchSeq2SeqWrapper","``",".","This","lets","us","use","this","class","in","the","registry","and","have","everything","just","work","."]
code: def __init__(self, module_class):
      self._module_class = module_class
  
file_path: magnitude/pymagnitude/third_party/allennlp/modules/seq2seq_encoders/__init__.py
imports: from __future__ import absolute_import
  import logging
  import torch
  from allennlp.common import Params
  from allennlp.common.checks import ConfigurationError
  from allennlp.modules.augmented_lstm import AugmentedLstm
  from allennlp.modules.seq2seq_encoders.intra_sentence_attention import IntraSentenceAttentionEncoder
  from allennlp.modules.seq2seq_encoders.pytorch_seq2seq_wrapper import PytorchSeq2SeqWrapper
  from allennlp.modules.seq2seq_encoders.seq2seq_encoder import Seq2SeqEncoder
  from allennlp.modules.stacked_alternating_lstm import StackedAlternatingLstm
  from allennlp.modules.stacked_bidirectional_lstm import StackedBidirectionalLstm
  from allennlp.modules.seq2seq_encoders.stacked_self_attention import StackedSelfAttentionEncoder
  from allennlp.modules.seq2seq_encoders.multi_head_self_attention import MultiHeadSelfAttention
  from allennlp.modules.seq2seq_encoders.pass_through_encoder import PassThroughEncoder
label_desc: Use image node_id 1 to create a new _Seq2SeqWrapper object from inherited base classes: object with example: obj = _Seq2SeqWrapper(module_class)