This kind of error is happening to me help!!!
It runs good in my size of  this
        vocab_size:	20
	embedding_dim:	15
	hidden_dim:	10
	n_layers:	2
	output_size:	10

but gives wrong output and error like
RuntimeError: index out of range at /opt/conda/conda-bld/pytorch_1524584710464/work/aten/src/TH/generic/THTensorMath.c:343
in this sizes
vocab_size:	72	
embedding_dim:	256	
hidden_dim:	256	
n_layers:	3	
output_size:	72

My code is below
import torch.nn as nn

class RNN(nn.Module):
    
    def __init__(self, vocab_size, output_size, embedding_dim, hidden_dim, n_layers, dropout=0.5):
        """
        :param vocab_size: The number of input dimensions of the neural network (the size of the vocabulary)
        :param output_size: The number of output dimensions of the neural network
        :param embedding_dim: The size of embeddings, should you choose to use them        
        :param hidden_dim: The size of the hidden layer outputs
        :param dropout: dropout to add in between LSTM/GRU layers
        """
        super(RNN, self).__init__()
        # TODO: Implement function

        
        # set class variables
        self.output_size = output_size
        self.n_layers = n_layers
        self.hidden_dim = hidden_dim
        self.embedding_dim = embedding_dim
        self.vocab_size = vocab_size
        print('vocab_size:', self.vocab_size,
              'embedding_dim:', self.embedding_dim,
              'hidden_dim:',self.hidden_dim,
              'n_layers:',self.n_layers,
              'output_size:',self.output_size,
              sep='\t'
             )
        # define model layers
        self.embedding = nn.Embedding(vocab_size, embedding_dim)
        self.lstm = nn.LSTM(embedding_dim, hidden_dim, n_layers, dropout=dropout, batch_first=True)
        
         
        #linear layer
        self.dropout = nn.Dropout(0.3)
        self.fc = nn.Linear(hidden_dim,output_size)
        self.sig = nn.Sigmoid()
    
    
    def forward(self, nn_input, hidden):
        """
        Forward propagation of the neural network
        :param nn_input: The input to the neural network
        :param hidden: The hidden state        
        :return: Two Tensors, the output of the neural network and the latest hidden state
        """

        # TODO: Implement function  
        #get the batch size
        batch_size = nn_input.size(0)

        #change to long tensor
        nn_input = nn_input.long()
        
        #embedding and lstm_out
        embeds = self.embedding(nn_input)
        
        lstm_out, hidden = self.lstm(embeds,hidden)
        
        #stack up lstm outputs
        lstm_out = lstm_out.contiguous().view(-1, self.hidden_dim)
        
        #dropout and fully-connected layer
        out = self.dropout(lstm_out)
        out = self.fc(out)
        
        out = out.view(batch_size, -1, self.output_size)
        
        out = out[:, -1] # last batch of labels
        
        
        # return one batch of output word scores and the hidden state
        return out, hidden
    
    
    def init_hidden(self, batch_size):
        '''
        Initialize the hidden state of an LSTM/GRU
        :param batch_size: The batch_size of the hidden state
        :return: hidden state of dims (n_layers, batch_size, hidden_dim)
        '''
        # Implement function
        weight = next(self.parameters()).data
        # initialize hidden state with zero weights, and move to GPU if available
        if(train_on_gpu):
            hidden = (weight.new(self.n_layers, batch_size, self.hidden_dim).zero_().cuda(),
                      weight.new(self.n_layers, batch_size, self.hidden_dim).zero_().cuda())
        else:
            hidden = (weight.new(self.n_layers, batch_size, self.hidden_dim).zero_(),
                      weight.new(self.n_layers, batch_size, self.hidden_dim).zero_())
            
        return hidden

I tried to debug it it specifically started giving error  in
        self.embedding = nn.Embedding(vocab_size, embedding_dim)
Any help will be appretiated and Thank your for response.