class_docstr: The low-level interface dataset class
  
  Args:
      path_prefix (str): The index (.idx) and data (.bin) prefix
  
      multimodal (bool, optional): Whether the dataset is multimodal. Defaults to False.
class_docstr_tok: ["The","low-level","interface","dataset","class","Args",":","path_prefix","(","str",")",":","The","index","(",".idx",")","and","data","(",".bin",")","prefix","multimodal","(","bool",",","optional",")",":","Whether","the","dataset","is","multimodal",".","Defaults","to","False","."]
docstr: Return from the dataset
  
  Args:
      idx (Union[int, numpy.integer, slice]): The index or index slice into the dataset
  
  Raises:
      ValueError: When the index slice is non-contiguous
  
      TypeError: When the index is of an unexpected type
  
  Returns:
      Union[numpy.ndarray, Tuple[numpy.ndarray, numpy.ndarray]]: The sequence tokens and
      modes at the index or index slice
docstr_tok: ["Return","from","the","dataset","Args",":","idx","(","Union","[","int",",","numpy.integer",",","slice","]",")",":","The","index","or","index","slice","into","the","dataset","Raises",":","ValueError",":","When","the","index","slice","is","non-contiguous","TypeError",":","When","the","index","is","of","an","unexpected","type","Returns",":","Union","[","numpy.ndarray",",","Tuple","[","numpy.ndarray",",","numpy.ndarray","]","]",":","The","sequence","tokens","and","modes","at","the","index","or","index","slice"]
code: def __getitem__(
      self, idx: Union[int, numpy.integer, slice]
  ) -> Union[numpy.ndarray, Tuple[numpy.ndarray, numpy.ndarray]]:
      """Return from the dataset
  
      Args:
          idx (Union[int, numpy.integer, slice]): The index or index slice into the dataset
  
      Raises:
          ValueError: When the index slice is non-contiguous
  
          TypeError: When the index is of an unexpected type
  
      Returns:
          Union[numpy.ndarray, Tuple[numpy.ndarray, numpy.ndarray]]: The sequence tokens and
          modes at the index or index slice
      """
      if isinstance(idx, (int, numpy.integer)):
          sequence_pointer, sequence_length, sequence_mode = self.index[
              idx
          ]
          sequence = numpy.frombuffer(
              self.bin_buffer,
              dtype=self.index.dtype,
              count=sequence_length,
              offset=sequence_pointer,
          )
          return (
              (sequence, sequence_mode)
              if sequence_mode is not None
              else sequence
          )
      elif isinstance(idx, slice):
          start, stop, step = idx.indices(len(self))
          if step != 1:
              raise ValueError(
                  "Slices into indexed_dataset must be contiguous"
              )
          sequence_lengths = self.index.sequence_lengths[idx]
          sequence_modes = (
              self.index.sequence_modes[idx]
              if self.multimodal
              else None
          )
          sequence_offsets = list(accumulate(sequence_lengths))
          sequences = numpy.split(
              numpy.frombuffer(
                  self.bin_buffer,
                  dtype=self.index.dtype,
                  count=sum(sequence_lengths),
                  offset=self.index.sequence_pointers[start],
              ),
              sequence_offsets[:-1],
          )
          return (
              (sequences, sequence_modes)
              if sequence_modes is not None
              else sequences
          )
      else:
          raise TypeError(
              "Unexpected type received for idx: {}".format(type(idx))
          )
  
imports: import logging
  import os
  import shutil
  import struct
  import time
  from enum import Enum
  from functools import lru_cache
  from itertools import accumulate
  from types import TracebackType
  from typing import List, Optional, Tuple, Type, Union
  import numpy
  import torch
  from megatron.core.datasets.utils import log_single_rank
label_desc: Use image node_id 7 for calling the MMapIndexedDataset obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: unknown, unknown