class_docstr: A wrapper of fairseq data iterator, usage:
  batch_itr = BatchIterator(fairseq_args, fairseq_task)
  for epoch in batch_itr.train_epoch():
      for batch in batch_itr.train_batch():
          train(batch)
          if should_valid():
              for sub in batch_itr.valid_dataset():
                  for sample in batch_itr.valid_batch():
                      valid(sample)
                  pirnt(f"Finish valid {sub}")
      print(f"Finish train epoch {epoch}")
code: def valid_dataset(self):
      args, task = self.args, self.task
      for subset in args.valid_subset.split(","):
          task.load_dataset(subset, combine=False, epoch=1)
          self.valid_itr = task.get_batch_iterator(
              dataset=task.dataset(subset),
              max_tokens=args.max_tokens_valid,
              max_sentences=args.batch_size_valid,
              max_positions=utils.resolve_max_positions(
                  task.max_positions(),
              ),
              ignore_invalid_inputs=args.skip_invalid_size_inputs_valid_test,
              required_batch_size_multiple=args.required_batch_size_multiple,
              seed=args.seed,
              num_shards=dist.get_world_size(),
              shard_id=dist.get_rank(),
              num_workers=args.num_workers,
              data_buffer_size=args.data_buffer_size,
              disable_iterator_cache=False,
          ).next_epoch_itr(shuffle=False)
          yield subset
  
file_path: lightseq/examples/training/deepspeed/ds_fairseq_data.py
imports: import math
  import logging
  import torch.distributed
  from fairseq import utils
label_desc: Use image node_id 7 for calling the BatchIterator obj's underlying member method code with example usage: obj.valid_dataset() without return types