class_docstr: Custom dataset for scientific PDF data.
  
  This dataset loads data from JSONL files and provides access to images, ground truth,
  and metadata.
  
  Args:
      path_to_index (str): Path to the index file.
      split (str, optional): Split of the dataset (e.g., "train", "test"). Default is "train".
      root_name (str, optional): Root directory name. Default is an empty string.
      template (str, optional): Template for split naming. Default is "%s".
  
  Attributes:
      empty_sample: Placeholder for empty samples.
code: def __init__(
      self,
      path_to_index: str,
      split: str = "train",
      root_name="",
      template="%s",
  ) -> None:
      super().__init__()
      self.path_to_index = Path(path_to_index)
      self.root_name = root_name
      self.path_to_root = self.path_to_index.parent
      if not split in self.path_to_index.stem:
          pti = self.path_to_root / (template % split + ".jsonl")
          if pti.exists():
              self.path_to_index = pti
          else:
              raise ValueError(
                  f'Dataset file for split "{split}" not found: {pti}'
              )
      self.dataset_file = None  # mulitprocessing
      # load seek map
      seek_path = self.path_to_root / (
          self.path_to_index.stem + ".seek.map"
      )
      if seek_path.exists():
          self.seek_map = orjson.loads(seek_path.open().read())
      else:
          raise ValueError(
              'No "%s" found in %s'
              % (seek_path.name, str(self.path_to_root))
          )
      self.dataset_length = len(self.seek_map)
  
imports: import logging
  import os
  from math import prod
  from pathlib import Path
  from functools import partial
  import random
  from typing import Dict, Tuple, Callable
  from PIL import Image, UnidentifiedImageError
  from typing import List, Optional
  import torch
  import pypdf
  import orjson
  from torch.utils.data import Dataset
  from transformers.modeling_utils import PreTrainedModel
  from nougat.dataset.rasterize import rasterize_paper
label_desc: Use image node_id 1 to create a new SciPDFDataset object from inherited base classes: Dataset with example: obj = SciPDFDataset(path_to_index, split, root_name, template)