Here is a fraction of the code:
def train(category_tensor, line_tensor):
    hidden = network.rnn.initHidden()

    network.rnn.zero_grad()

    for i in range(line_tensor.size()[0]):
        network.output, hidden = network.rnn(line_tensor[i], hidden)

    category_tensor = category_tensor.long()
    category_tensor = category_tensor.resize(57)

    loss = criterion(network.output, category_tensor)
    loss.backward()

    # Update values of parameters, gradients * learning rate
    for p in network.rnn.parameters():
        p.data.add_(-learning_rate, p.grad.data)

    return network.output, loss.data[0]


# ------------------------------- Track Losses -------------------------------

n_iters = 100000
print_every = 5000
plot_every = 1000

current_loss = 0
all_losses = []

def timeSince(since):
    now = time.time()
    s = now - since
    m = math.floor(s / 60)
    s -= m * 60
    return '%dm %ds' % (m, s)

start = time.time()

for iter in range(1, n_iters + 1):
    preprocessing.category, line, category_tensor, line_tensor = randomTrainingExample()
    network.output, loss = train(category_tensor, line_tensor)
    current_loss += loss