code: def __iter__(self) -> Iterator[Any]:
      from pyspark.sql.pandas.serializers import ArrowStreamSerializer
  
      serializer = ArrowStreamSerializer()
  
      worker_info = torch.utils.data.get_worker_info()
      if worker_info is not None and worker_info.num_workers > 1:
          raise RuntimeError(
              "SparkPartitionTorchDataset does not support multiple worker processes."
          )
  
      count = 0
  
      while count < self.num_samples:
          with open(self.arrow_file_path, "rb") as f:
              batch_iter = serializer.load_stream(f)
              for batch in batch_iter:
                  # TODO: we can optimize this further by directly extracting
                  #  field data from arrow batch without converting it to
                  #  pandas DataFrame.
                  batch_pdf = batch.to_pandas()
                  for row in batch_pdf.itertuples(index=False):
                      yield [
                          field_converter(value)
                          for value, field_converter in zip(
                              row, self.field_converters
                          )
                      ]
                      count += 1
                      if count == self.num_samples:
                          return
  
file_path: spark/python/pyspark/ml/torch/data.py
imports: from typing import Any, Callable, Iterator
  import torch
  import numpy
  from pyspark.sql.types import StructType
label_desc: Use image node_id 3 for calling the _SparkPartitionTorchDataset obj's underlying member method code with example usage: obj.__iter__() without return types