class_docstr: Iterator that caches a number of indices sampled according to given weights.
  
  This gives a great performance speedup since np.random.choice is the bottleneck
  of the data loading. This class samples and caches a certain number of indices and
  return them until new ones need to be sampled.
class_docstr_tok: ["Iterator","that","caches","a","number","of","indices","sampled","according","to","given","weights",".","This","gives","a","great","performance","speedup","since","np.random.choice","is","the","bottleneck","of","the","data","loading",".","This","class","samples","and","caches","a","certain","number","of","indices","and","return","them","until","new","ones","need","to","be","sampled","."]
code: def __iter__(self):
      self.i = self.num_cache
      return self
  
imports: from __future__ import annotations
  import numpy
  import pandas
  from dataclasses import dataclass, fields
  from typing import Iterator, List, Optional
  import torch
  from torch.utils.data import IterableDataset, Dataset
  from .dataset import TimeSeries, TimeSeriesDataset
label_desc: Use image node_id 2 for calling the WeightedIndexIterator obj's underlying member method code with example usage: obj.__iter__() and returns: self