import numpy as np
import matplotlib.pyplot as plt
import requests
from io import BytesIO

# Load data
response = requests.get("https://users.uop.gr/~nikolentzos/files/mnist.npz")
response.raise_for_status()
data = np.load(BytesIO(response.content))

# Training data
X_train = data["X_train"]
X_train = X_train / 255.0 # normalize pixel values
y_train = data["y_train"]
print('Size of training matrix:', X_train.shape)
print('Size of training targets:', y_train.shape)

# Test data
X_test  = data["X_test"]
X_test = X_test / 255.0 # normalize pixel values
y_test  = data["y_test"]
print('Size of test matrix:', X_test.shape)
print('Size of test targets:', y_test.shape)

# Visualize first 5 digits
plt.figure(figsize=(10,2))
for i in range(5):
    plt.subplot(1, 5, i+1)
    plt.imshow(X_train[i], cmap="gray")
    plt.title(y_train[i])
    plt.axis("off")

plt.show()

################
#your code here#
################