code: def find_list_from_index(
      pattern_idx: int,
      list_sizes: Sequence[int],
      max_size: int,
      cumulative_sizes=None,
  ):
      if pattern_idx >= max_size:
          raise IndexError()
  
      if cumulative_sizes is None:
          r, s = [], 0
          for list_len in list_sizes:
              r.append(list_len + s)
              s += list_len
          cumulative_sizes = r
  
      list_idx = bisect.bisect_right(cumulative_sizes, pattern_idx)
      if list_idx != 0:
          pattern_idx = pattern_idx - cumulative_sizes[list_idx - 1]
  
      if pattern_idx >= list_sizes[list_idx]:
          raise ValueError(
              "Index out of bounds, wrong max_size parameter"
          )
      return list_idx, pattern_idx
  
imports: from abc import ABC, abstractmethod
  import bisect
  import copy
  from typing import Iterator, overload
  from typing_extensions import final
  import numpy
  from numpy import ndarray
  from torch import Tensor
  from torch.utils.data import Subset
  from .dataset_definitions import IDatasetWithTargets
  from typing import Sequence, List, Iterable, Union, Optional, TypeVar, Callable, Generic
label_desc: Use image node_id 1 for calling a global function with example usage: find_list_from_index(pattern_idx, list_sizes, max_size, cumulative_sizes) and returns: list_idx,  pattern_idx