class_docstr: Yield batch from (multiple) plain text corpus.
  
  Args:
      corpora (dict[str, ParallelCorpus]): collections of corpora to iterate;
      corpora_info (dict[str, dict]): corpora infos correspond to corpora;
      transforms (dict[str, Transform]): transforms may be used by corpora;
      vocabs (dict[str, Vocab]): vocab dict for convert corpora into Tensor;
      task (str): CorpusTask.TRAIN/VALID/INFER;
      batch_type (str): batching type to count on, choices=[tokens, sents];
      batch_size (int): numbers of examples in a batch;
      batch_size_multiple (int): make batch size multiply of this;
      data_type (str): input data type, currently only text;
      bucket_size (int): accum this number of examples in a dynamic dataset;
      bucket_size_init (int): initialize the bucket with this
      amount of examples;
      bucket_size_increment (int): increment the bucket
      size with this amount of examples;
      copy (Bool): if True, will add specific items for copy_attn
      skip_empty_level (str): security level when encouter empty line;
      stride (int): iterate data files with this stride;
      offset (int): iterate data files with this offset.
  
  Attributes:
      sort_key (function): functions define how to sort examples;
      mixer (MixingStrategy): the strategy to iterate corpora.
docstr: Initilize `DynamicDatasetIter` with options parsed from `opt`.
code: def from_opt(
      cls,
      corpora,
      transforms,
      vocabs,
      opt,
      task,
      copy,
      device,
      stride=1,
      offset=0,
  ):
      """Initilize `DynamicDatasetIter` with options parsed from `opt`."""
      corpora_info = {}
      batch_size = (
          opt.valid_batch_size
          if (task == CorpusTask.VALID)
          else opt.batch_size
      )
      if task != CorpusTask.INFER:
          if opt.batch_size_multiple is not None:
              batch_size_multiple = opt.batch_size_multiple
          else:
              batch_size_multiple = (
                  8 if opt.model_dtype == "fp16" else 1
              )
          corpora_info = opt.data
          bucket_size = opt.bucket_size
          bucket_size_init = opt.bucket_size_init
          bucket_size_increment = opt.bucket_size_increment
          skip_empty_level = opt.skip_empty_level
      else:
          batch_size_multiple = 1
          corpora_info[CorpusTask.INFER] = {
              "transforms": opt.transforms
          }
          corpora_info[CorpusTask.INFER]["weight"] = 1
          # bucket_size = batch_size
          bucket_size = 16384
          bucket_size_init = -1
          bucket_size_increment = 0
          skip_empty_level = "warning"
      return cls(
          corpora,
          corpora_info,
          transforms,
          vocabs,
          task,
          opt.batch_type,
          batch_size,
          batch_size_multiple,
          data_type=opt.data_type,
          bucket_size=bucket_size,
          bucket_size_init=bucket_size_init,
          bucket_size_increment=bucket_size_increment,
          copy=copy,
          device=device,
          skip_empty_level=skip_empty_level,
          stride=stride,
          offset=offset,
      )
  
imports: import torch
  from itertools import cycle
  from onmt.constants import CorpusTask, ModelTask
  from onmt.inputters.text_corpus import get_corpora, build_corpora_iters
  from onmt.inputters.text_utils import text_sort_key, process, numericalize, tensorify, _addcopykeys
  from onmt.transforms import make_transforms
  from onmt.utils.logging import init_logger, logger
  from onmt.utils.misc import RandomShuffler
  from torch.utils.data import DataLoader
label_desc: Use image node_id 2 for calling the DynamicDatasetIter obj's underlying member method code with example usage: obj.from_opt(cls, corpora, transforms, vocabs, opt, task, copy, device, stride, offset) and returns: cls