What should be 'y_train' in Keras LSTM? I refer to the example given at the Keras website here:

from keras.models import Sequential
from keras.layers import LSTM, Dense
import numpy as np

data_dim = 16
timesteps = 8
num_classes = 10

# expected input data shape: (batch_size, timesteps, data_dim)
model = Sequential()
model.add(LSTM(32, return_sequences=True,
       input_shape=(timesteps, data_dim)))  # returns a sequence of vectors of dimension 32
model.add(LSTM(32, return_sequences=True))  # returns a sequence of vectors of dimension 32
model.add(LSTM(32))  # return a single vector of dimension 32
model.add(Dense(10, activation='softmax'))

model.compile(loss='categorical_crossentropy', optimizer='rmsprop', metrics=['accuracy'])

# Generate dummy training data
x_train = np.random.random((1000, timesteps, data_dim))
y_train = np.random.random((1000, num_classes))

# Generate dummy validation data
x_val = np.random.random((100, timesteps, data_dim))
y_val = np.random.random((100, num_classes))

model.fit(x_train, y_train, batch_size=64, epochs=5, validation_data=(x_val, y_val))


For a real-world example, what should be y_train and y_val? Should they be the same as x_train and x_val respectively, since they come from the same sequence?

Also, how should I understand data_dim and num_classes?
'y_train' and 'y_val' should be whatever it is you are trying to predict. They can be values, classes, or they can be a sequence. The form of what you are trying to predict will influence how you structure a RNN in Keras: Many to one and many to many LSTM examples in Keras.
'data_dim' is the number of features in the dataset. If you are predicting the weather, the features may be 'pressure', 'temperature, 'precipitation', and so 'data_dim' = 3.
'num_classes' is the number of classes that the outcome variable can assume. If the outcome variable is 'type of animal', and the classes the outcome variable can assume are 'dog', 'cat', 'bird', then 'num_classes' = 3.