human
Give me a the Python code you requested given the following:
I am working on the file "DL0110EN/2.3.1stochastic_gradient_descent_v2.ipynb".
The first task is:
Create a dataset class:
Can you write Python code for it?
assistant
#Here is the Python code you requested.

# Dataset Class

class Data(Dataset):
    
    # Constructor
    def __init__(self):
        self.x = torch.arange(-3, 3, 0.1).view(-1, 1)
        self.y = 1 * self.x - 1
        self.len = self.x.shape[0]
        
    # Getter
    def __getitem__(self,index):    
        return self.x[index], self.y[index]
    
    # Return the length
    def __len__(self):
        return self.len