example = [1,2,3,4,5,6,7,8,9,10,11] should be smaller than num_hidden (i.e. 9 is the most)
example = [1,2,3,1,5,4,7,2,7,9,0]
also there is something wrong with data size.
BTW It would be better to paste a snippet that could work directly in someone other’s environ.
one version that workd for you:
import torch
from torch import nn
from torch.autograd import Variable

class myRNN(nn.Module):
    def __init__(self, input_size, hidden_size, num_layer):
        super(myRNN, self).__init__()
        self.input_size = input_size
        self.hidden_size = hidden_size
        self.num_layer = num_layer

        self.rnn1 = nn.RNN(input_size, hidden_size, num_layer)
        #input_size, hidden_size, num_layer
        #hidden_size 는 한 layer내의 block size

    def forward(self, input, hidden):
        output, hidden = self.rnn1(input, hidden)
        return output, hidden

    def init_hidden(self):
        hidden = Variable(torch.zeros(num_layer, batch_size, hidden_size))
        return hidden



if __name__ == '__main__':

    
    input_size = 1
    hidden_size = 10
    num_layer = 1
    batch_size = 1

    #
    rnn = myRNN(input_size, hidden_size, num_layer)
    #loss, optimizer
    optimizer = torch.optim.Adam(rnn.parameters(), lr = 0.0001)

    example = [1,2,3,1,3,5,4,7,2,2,7,2,9,0]
    seq_len = len(example)-1
    # change hre
    input_data = Variable(torch.FloatTensor(example[:-1]).view(-1, batch_size,  input_size))
    label = Variable(torch.FloatTensor(example[1:]).view(-1, batch_size, input_size))
    print(input_data.size(), label.size())



    hidden = rnn.init_hidden()
    print(hidden.size())


    hidden = rnn.init_hidden()
    loss = 0
    optimizer.zero_grad()
    output, hidden = rnn(input_data, hidden)

    print('output / label' , output.size(), label.size())
     
    #modify here
    output = output.view(-1,hidden_size)
    label = label.long().view(-1)
    loss = nn.functional.nll_loss(output, label)
    loss.backward()
    optimizer.step()
    print(loss)