I have a seq2seq network (a class) which is trained and model states are saved without any problem. [Please note, I am using DataParallel]
Constructor of that class.
class Sequence2Sequence(nn.Module):
    """Class that classifies question pair as duplicate or not."""

    def __init__(self, dictionary, embedding_index, max_sent_length, args):
        """"Constructor of the class."""
        super(Sequence2Sequence, self).__init__()
        self.dictionary = dictionary
        self.embedding_index = embedding_index
        self.config = args
        self.encoder = Encoder(len(self.dictionary), self.config)
        self.decoder = AttentionDecoder(len(self.dictionary), max_sent_length, self.config)
        self.criterion = nn.NLLLoss()  # Negative log-likelihood loss

        # Initializing the weight parameters for the embedding layer in the encoder.
        self.encoder.init_embedding_weights(self.dictionary, self.embedding_index, self.config.emsize)

Now for testing, I wrote the following in my test function.
def test(model, batch_sentence):
    if model.config.model == 'LSTM':
        encoder_hidden, encoder_cell = model.encoder.init_weights(batch_sentence.size(0))
        output, hidden = model.encoder(batch_sentence, (encoder_hidden, encoder_cell))
    else:
        encoder_hidden = model.encoder.init_weights(batch_sentence.size(0))
        output, hidden = model.encoder(batch_sentence, encoder_hidden)

In the first line of the test function, I am getting the following error.
AttributeError: type object 'object' has no attribute '__getattr__'
Any idea why it is not working?