human
I am working on the file "DL0110EN/2.5.2_early_stopping_v2.ipynb".
The first task is:
<!--Empty Space for separating topics-->

<h2 id="#Makeup_Data">Make Some Data</h2>

First let's create some artificial data, in a dataset class.  The class will include the option to produce training data or validation data. The training data includes outliers.
Can you write Python code for it?
 ... What is a the Python code you requested?
assistant
#Here is the Python code you requested.

# Create Data Class

class Data(Dataset):
    
    # Constructor
    def __init__(self, train = True):
        if train == True:
            self.x = torch.arange(-3, 3, 0.1).view(-1, 1)
            self.f = -3 * self.x + 1
            self.y = self.f + 0.1 * torch.randn(self.x.size())
            self.len = self.x.shape[0]
            if train == True:
                self.y[50:] = 20
        else:
            self.x = torch.arange(-3, 3, 0.1).view(-1, 1)
            self.y = -3 * self.x + 1
            self.len = self.x.shape[0]
            
    # Getter
    def __getitem__(self, index):    
        return self.x[index], self.y[index]
    
    # Get Length
    def __len__(self):
        return self.len