It was my mistake as I assumed encoded was a tensor, but apparently it it a numpy array, which does not have these methods.
Have a look at these debug outputs to see, how the array is being reshaped and how x and y are created:
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))
    print('arr after reshape\n', arr)
    
    #İ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

arr = np.arange(500)
print('result\n', next(get_batches(arr, 8, 10)))

As you can see, arr is being reshaped in a continuous manner and then sliced, such that these gaps are created.