import torch


def synthetic_data(w, b, num_examples):
    """
    Generate y = Xw + b + noise.
    """
    X = torch.normal(0, 1, (num_examples, len(w)))
    y = torch.matmul(X, w) + b
    y += torch.normal(0, 0.01, y.shape)
    return X, y.reshape((-1, 1))