code: def __iter__(self):
      worker_info = torch.utils.data.get_worker_info()
      if worker_info is None:
          iter_start = self.start
          iter_end = self.end
      else:
          per_worker = int(
              math.ceil(
                  (self.end - self.start)
                  / float(worker_info.num_workers)
              )
          )
          worker_id = worker_info.id
          iter_start = self.start + worker_id * per_worker
          iter_end = min(iter_start + per_worker, self.end)
  
      for idx in range(iter_start, iter_end):
          if self.dataset == "20newsgroups":
              review = str(self.source["description"].iloc[idx])
              target = int(self.source["label"].iloc[idx])
          else:
              target, review = self.source[idx]
              target -= 1
          encoding = self.tokenizer.encode_plus(
              review,
              add_special_tokens=True,
              max_length=self.max_length,
              return_token_type_ids=False,
              padding="max_length",
              return_attention_mask=True,
              return_tensors="pt",
              truncation=True,
          )
  
          yield {
              "review_text": review,
              "input_ids": encoding["input_ids"].flatten(),
              "attention_mask": encoding["attention_mask"].flatten(),
              "targets": torch.tensor(target, dtype=torch.long),
          }
  
imports: import math
  import os
  import lightning
  import pandas
  import torch
  import torch.nn.functional
  import torchtext.datasets
  from lightning.pytorch.callbacks import EarlyStopping, LearningRateMonitor, ModelCheckpoint
  from lightning.pytorch.cli import LightningCLI
  from sklearn.datasets import fetch_20newsgroups
  from sklearn.metrics import accuracy_score
  from sklearn.model_selection import train_test_split
  from torch import nn
  from torch.utils.data import DataLoader
  from torch.utils.data.dataset import random_split
  from torchdata.datapipes.iter import IterDataPipe
  from torchtext.data.functional import to_map_style_dataset
  from torchtext.datasets import AG_NEWS
  from transformers import BertModel, BertTokenizer
  import mlflow.pytorch
label_desc: Use image node_id 2 for calling the NewsDataset obj's underlying member method code with example usage: obj.__iter__() without return types