First of all, thank you so much sir! you answered my 5 question clearly and it was awesome. But i see it was really hard to work with batches, i understand more than yesterday. In this example too many array data flow and i try to understand completely.
Secondly, i try to call encoded = encoded.contiguous() but i get AttributeError: ‘numpy.ndarray’ object has no attribute ‘contiguous’ error and also arr.view has TypeError: data type not understood. i really don’t catch how we get second row of batch. i printed 1000 character of encoded line and search. but i couldnt match. and also why i got this 2 error. i can understand arr.view error it is different from reshape. but why does the contiguous have an error. now i try to understand why you offer contiguous and i lost in stackoverflow PyTorch - contiguous() 3 
This is my all code. I think i missed something.
import numpy as np
import torch
from torch import nn
import torch.nn.functional as F

with open('anna.txt', 'r') as f:
    text = f.read()
    
text[:100]

#encode text map character to integer 

chars = tuple(set(text))
int2char = dict(enumerate(chars))
char2int = {ch: ii for ii, ch in int2char.items()}

#encode text
encoded = np.array([char2int[ch] for ch in text])
encoded[:100]

'''ONE HOT ENCODE'''
def one_hot_encode(arr, n_labels):
    
    # Initialize the the encoded array
    one_hot = np.zeros((np.multiply(*arr.shape), n_labels), dtype=np.float32)
    
    # Fill the appropriate elements with ones
    one_hot[np.arange(one_hot.shape[0]), arr.flatten()] = 1.
    
    # Finally reshape it to get back to the original array
    one_hot = one_hot.reshape((*arr.shape, n_labels))
    
    return one_hot

#check function works
test_seq = np.array([[2,7,1]])
one_hot = one_hot_encode(test_seq, 8)

print(one_hot)
type(one_hot)

'''CREATING BATCHES'''
def get_batches(arr, batch_size, seq_length):
    #bu batch_size X seq_length lik arrayler oluşturur arr'dan
    # arr = batch'lere ayrılacak dizi
    #batch_size = 1 batch içindeki sequencelerin sayısı
    #seq_length  = encoded char'ların sayısı bir sequence'deki
    
    batch_size_total = batch_size * seq_length
    #K değerimiz total number of batches yapabileceğimiz
    n_batches = len(arr) // batch_size_total
    
    #full batch'ler yapmak için gerekli olan yeterli karakteri tutuyoruz
    arr = arr[:n_batches * batch_size_total]
    #reshape batch_size 'ı rowlara verdik
    arr = arr.reshape((batch_size, -1))
    
    
    #İTERATE array boyunca. 1 sequence her seferinde
    for n in range(0, arr.shape[1], seq_length):
        #the features
        x = arr[:, n: n+seq_length]
        
        #the targets, shifted by one
        y=np.zeros_like(x)
        
        try:
            y[:, :-1], y[:, -1] = x[:, 1:], arr[:, n+seq_length]
        except IndexError:
            y[:, :-1], y[:,-1] = x[:,1:], arr[:, 0]
        yield x, y

### TEST YOUR IMPLEMENTION
batches = get_batches(encoded, 8, 50)
x,y = next(batches)
#sequence'deki ilk 10 item'i yazdırıyoruz
print('x\n', x[:,:])
print('\ny\n', y[:10,:10])
print('\nencoded\n', encoded[:1000])