Complete the code to import the Dataset class from PyTorch.
from torch.utils.data import [1]
The Dataset class is imported from torch.utils.data to create custom datasets.
Complete the code to define the __len__ method that returns the dataset size.
def __len__(self): return [1]
The __len__ method returns the number of samples in the dataset, usually by returning len(self.data).
Fix the error in the __getitem__ method to return the correct data sample.
def __getitem__(self, idx): sample = self.data[[1]] return sample
The __getitem__ method uses the argument idx to access the data sample at that index.
Fill both blanks to create a dictionary comprehension that maps words to their lengths for words longer than 3 characters.
lengths = {word: [1] for word in words if len(word) [2] 3}The dictionary comprehension maps each word to its length using len(word) and filters words with length greater than 3 using >.
Fill all three blanks to create a dictionary comprehension that maps uppercase keys to values for items with positive values.
result = [1]: [2] for k, v in data.items() if v [3] 0}
The comprehension uses k.upper() as keys, v as values, and filters items where v > 0.