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 _train_epoch(self, epoch):
      args, task = self.args, self.task
      if epoch == 1 or task.has_sharded_data("train"):
          task.load_dataset(
              args.train_subset,
              epoch=epoch,
              combine=True,
              data_selector=None,
          )
  
      self.itr = task.get_batch_iterator(
          dataset=task.dataset(args.train_subset),
          max_tokens=args.max_tokens,
          max_sentences=args.batch_size,
          max_positions=utils.resolve_max_positions(
              task.max_positions(),
              args.max_tokens,
          ),
          ignore_invalid_inputs=True,
          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,
          epoch=epoch,
          data_buffer_size=args.data_buffer_size,
          disable_iterator_cache=task.has_sharded_data("train"),
      )
  
      self.itr = self.itr.next_epoch_itr(
          fix_batches_to_gpus=args.fix_batches_to_gpus,
          shuffle=(epoch > args.curriculum),
      )
  
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 2 for calling the BatchIterator obj's underlying member method code with example usage: obj._train_epoch(epoch) without return types