docstr: Augments source and target ids in the batches with padding symbol
  to make the lengths of all sentences in the batches equal.
docstr_tok: ["Augments","source","and","target","ids","in","the","batches","with","padding","symbol","to","make","the","lengths","of","all","sentences","in","the","batches","equal","."]
code: def pad_batches(self, src_ids, tgt_ids, batch_indices):
      """
      Augments source and target ids in the batches with padding symbol
      to make the lengths of all sentences in the batches equal.
      """
  
      batches = {}
      for batch_idx, b in enumerate(batch_indices):
          src_len = max([len(src_ids[i]) for i in b])
          tgt_len = max([len(tgt_ids[i]) for i in b])
          src_ids_ = self.src_pad_id * np.ones(
              (len(b), src_len), dtype=np.int64
          )
          tgt_ids_ = self.tgt_pad_id * np.ones(
              (len(b), tgt_len), dtype=np.int64
          )
          for i, sentence_idx in enumerate(b):
              src_ids_[i][: len(src_ids[sentence_idx])] = src_ids[
                  sentence_idx
              ]
              tgt_ids_[i][: len(tgt_ids[sentence_idx])] = tgt_ids[
                  sentence_idx
              ]
          batches[batch_idx] = {"src": src_ids_, "tgt": tgt_ids_}
      return batches
  
imports: import io
  import json
  import pickle
  from collections import OrderedDict
  from dataclasses import dataclass
  from typing import Any, List, Optional
  import braceexpand
  import numpy
  import webdataset
  from torch.utils.data import IterableDataset
  from nemo.collections.nlp.data.data_utils.data_preprocessing import dataset_to_ids
  from nemo.core import Dataset
  from nemo.utils import logging
label_desc: Use image node_id 5 for calling the TranslationDataset obj's underlying member method code with example usage: obj.pad_batches(src_ids, tgt_ids, batch_indices) and returns: batches