class_docstr: Abstract class for TextMemmapSequenceToSequenceDataset and BinarizedMemmapSequenceToSequenceDataset.
  This class is not meant to be used standalone and just as an abstract class for the two subclasses.
class_docstr_tok: ["Abstract","class","for","TextMemmapSequenceToSequenceDataset","and","BinarizedMemmapSequenceToSequenceDataset",".","This","class","is","not","meant","to","be","used","standalone","and","just","as","an","abstract","class","for","the","two","subclasses","."]
code: def __getitem__(self, idx):
      src, tgt = self._get_sample(idx)
      offset = 0
      if self.add_bos_to_enc:
          offset += 1
      if self.add_eos_to_enc:
          offset += 1
      if self.prepend_id is not None:
          offset += 1
  
      if len(src) > self.max_src_seq_length - offset:
          src = src[: self.max_src_seq_length - offset]
  
      if self.add_bos_to_enc:
          src = np.concatenate([[self.src_tokenizer.bos_id], src])
  
      if self.prepend_id is not None:
          src = np.concatenate([[self.prepend_id], src])
  
      if self.add_eos_to_enc:
          src = np.concatenate([src, [self.src_tokenizer.eos_id]])
  
      if len(tgt) > self.max_tgt_seq_length - 2:
          tgt = tgt[: self.max_tgt_seq_length - 2]
  
      text_dec = np.concatenate([[self.tgt_tokenizer.bos_id], tgt])
      labels = np.concatenate([tgt, [self.tgt_tokenizer.eos_id]])
  
      return {"text_enc": src, "text_dec": text_dec, "labels": labels}
  
imports: import os
  import numpy
  import torch
  from nemo.collections.common.tokenizers.tokenizer_spec import TokenizerSpec
  from nemo.collections.nlp.data.language_modeling.megatron.dataset_utils import get_indexed_dataset_, get_samples_mapping
  from nemo.collections.nlp.data.language_modeling.text_memmap_dataset import TextMemMapDataset
  from nemo.core.classes import Dataset
  from nemo.utils import logging
label_desc: Use image node_id 4 for calling the IndexedSequenceToSequenceDataset obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: dict