the Training is stopped for my PyTorch model
I am creating a model to identify names of items in RNN (LITMS)
i get data , then transform data then create Baches then create Model then create train function Correctly but the training is stop here(not working):

this this my code
        for e in range(epochs):
        
            # initialize hidden state
            h = net.init_hidden(batch_size)
            
            for x, y in get_batches(data, batch_size, seq_length):
                print (&quot;the login the loob get_batches is succressfuly&quot;)
                counter += 1
                
                # One-hot encode our data and make them Torch tensors
                x = one_hot_encode(x, n_chars)
                inputs, targets = torch.from_numpy(x), torch.from_numpy(y)
                
                if(train_on_gpu):
                    inputs, targets = inputs.cuda(), targets.cuda()

                # Creating new variables for the hidden state, otherwise
                # we'd backprop through the entire training history
                h = tuple([each.data for each in h])

                # zero accumulated gradients
                net.zero_grad()
                
                # get the output from the model
                output, h = net(inputs, h)
                
                # calculate the loss and perform backprop
                loss = criterion(output, targets.view(batch_size*seq_length))
                loss.backward()
                # `clip_grad_norm` helps prevent the exploding gradient problem in RNNs / LSTMs.
                nn.utils.clip_grad_norm_(net.parameters(), clip)
                opt.step()
                
                # loss stats
                if counter % print_every == 0:
                    # Get validation loss
                    val_h = net.init_hidden(batch_size)
                    val_losses = []
                    net.eval()
                    for x, y in get_batches(val_data, batch_size, seq_length):
                        # One-hot encode our data and make them Torch tensors
                        x = one_hot_encode(x, n_chars)
                        x, y = torch.from_numpy(x), torch.from_numpy(y)
                        
                        # Creating new variables for the hidden state, otherwise
                        # we'd backprop through the entire training history
                        val_h = tuple([each.data for each in val_h])
                        
                        inputs, targets = x, y
                        if(train_on_gpu):
                            inputs, targets = inputs.cuda(), targets.cuda()

                        output, val_h = net(inputs, val_h)
                        val_loss = criterion(output, targets.view(batch_size*seq_length))
                    
                        val_losses.append(val_loss.item())
                    
                    net.train() # reset to train mode after iterationg through validation data
                    
                    print(&quot;Epoch: {}/{}...&quot;.format(e+1, epochs),
                        &quot;Step: {}...&quot;.format(counter),
                        &quot;Loss: {:.4f}...&quot;.format(loss.item()),
                        &quot;Val Loss: {:.4f}&quot;.format(np.mean(val_losses)))

I don't know why.
some times i got this error after many trials

please help me if you can
You can find the notebook file here.

you duplicate this step

remove it then try again
