class_docstr: Translate from one (source) language to another (target) language.
  
  Args:
      langs (List[str]): a list of languages that are being supported
      dicts (Dict[str, fairseq.data.Dictionary]): mapping from supported languages to their dictionaries
      training (bool): whether the task should be configured for training or not
  
  .. note::
  
      The translation task is compatible with :mod:`fairseq-train`,
      :mod:`fairseq-generate` and :mod:`fairseq-interactive`.
  
  The translation task provides the following additional command-line
  arguments:
  
  .. argparse::
      :ref: fairseq.tasks.translation_parser
      :prog:
class_docstr_tok: ["Translate","from","one","(","source",")","language","to","another","(","target",")","language",".","Args",":","langs","(","List","[","str","]",")",":","a","list","of","languages","that","are","being","supported","dicts","(","Dict","[","str",",","fairseq.data.Dictionary","]",")",":","mapping","from","supported","languages","to","their","dictionaries","training","(","bool",")",":","whether","the","task","should","be","configured","for","training","or","not","..","note",":",":","The","translation","task","is","compatible","with",":","mod",":","`","fairseq-train","`",",",":","mod",":","`","fairseq-generate","`","and",":","mod",":","`","fairseq-interactive","`",".","The","translation","task","provides","the","following","additional","command-line","arguments",":","..","argparse",":",":",":","ref",":","fairseq.tasks.translation_parser",":","prog",":"]
code: def create_batch_sampler_func(
      self,
      max_positions,
      ignore_invalid_inputs,
      max_tokens,
      max_sentences,
      required_batch_size_multiple=1,
      seed=1,
  ):
      def construct_batch_sampler(dataset, epoch):
          splits = [
              s
              for s, _ in self.datasets.items()
              if self.datasets[s] == dataset
          ]
          split = splits[0] if len(splits) > 0 else None
          # NEW implementation
          if epoch is not None:
              # initialize the dataset with the correct starting epoch
              dataset.set_epoch(epoch)
  
          # get indices ordered by example size
          start_time = time.time()
          logger.info(
              f"start batch sampler: mem usage: {data_utils.get_mem_usage()}"
          )
  
          with data_utils.numpy_seed(seed):
              indices = dataset.ordered_indices()
          logger.info(
              f"[{split}] @batch_sampler order indices time: {get_time_gap(start_time, time.time())}"
          )
          logger.info(f"mem usage: {data_utils.get_mem_usage()}")
  
          # filter examples that are too large
          if max_positions is not None:
              my_time = time.time()
              indices = self.filter_indices_by_size(
                  indices, dataset, max_positions, ignore_invalid_inputs
              )
              logger.info(
                  f"[{split}] @batch_sampler filter_by_size time: {get_time_gap(my_time, time.time())}"
              )
              logger.info(f"mem usage: {data_utils.get_mem_usage()}")
  
          # create mini-batches with given size constraints
          my_time = time.time()
          batch_sampler = dataset.batch_by_size(
              indices,
              max_tokens=max_tokens,
              max_sentences=max_sentences,
              required_batch_size_multiple=required_batch_size_multiple,
          )
  
          logger.info(
              f"[{split}] @batch_sampler batch_by_size time: {get_time_gap(my_time, time.time())}"
          )
          logger.info(
              f"[{split}] per epoch batch_sampler set-up time: {get_time_gap(start_time, time.time())}"
          )
          logger.info(f"mem usage: {data_utils.get_mem_usage()}")
  
          return batch_sampler
  
      return construct_batch_sampler
  
imports: import datetime
  import logging
  import time
  import torch
  from fairseq.data import FairseqDataset, LanguagePairDataset, ListDataset, data_utils, iterators
  from fairseq.data.multilingual.multilingual_data_manager import MultilingualDatasetManager
  from fairseq.data.multilingual.sampling_method import SamplingMethod
  from fairseq.tasks import LegacyFairseqTask, register_task
  from fairseq.utils import FileContentsAction
label_desc: Use image node_id 16 for calling the TranslationMultiSimpleEpochTask obj's underlying member method code with example usage: obj.create_batch_sampler_func(max_positions, ignore_invalid_inputs, max_tokens, max_sentences, required_batch_size_multiple, seed) and returns: construct_batch_sampler, batch_sampler