code: def _get_start_end_idx(
      n_items: int, page_sz: int, page_no: int
  ) -> Tuple[int, int]:
      assert page_sz > 0 and page_no > 0
      start_idx = min(page_sz * (page_no - 1), n_items - 1)
      end_idx = max(page_sz * page_no - 1, start_idx)
      # inclusive on both sides
      return start_idx, end_idx
  
file_path: vizseq/vizseq/_view/data_view.py
imports: from typing import Tuple, List, Iterable, NamedTuple, Dict, Optional
  import numpy
  from vizseq._data import VizSeqDataSources, VizSeqLanguageTagger
  from .data_sorters import VizSeqSortingType, VizSeqRandomSorter, VizSeqByLenSorter, VizSeqByStrOrderSorter, VizSeqByMetricSorter
  from .data_filter import VizSeqFilter
  from vizseq.scorers import get_scorer, get_scorer_ids
  from vizseq._visualizers import VizSeqSrcVisualizer, VizSeqRefVisualizer, VizSeqHypoVisualizer, VizSeqDictVisualizer
label_desc: Use image node_id 1 for calling a global function with example usage: _get_start_end_idx(n_items, page_sz, page_no) and returns: start_idx,  end_idx