class_docstr: Keeps track of the average time series length and adjusts the probability
  per time point such that on average `num_instances` training examples are
  generated per time series.
  
  Parameters
  ----------
  
  num_instances
      number of time points to sample per time series on average
  min_instances
      minimum number of time points to sample per time series
class_docstr_tok: ["Keeps","track","of","the","average","time","series","length","and","adjusts","the","probability","per","time","point","such","that","on","average","`","num_instances","`","training","examples","are","generated","per","time","series",".","Parameters","--","--","--","--","--","num_instances","number","of","time","points","to","sample","per","time","series","on","average","min_instances","minimum","number","of","time","points","to","sample","per","time","series"]
code: def __call__(self, ts: np.ndarray) -> np.ndarray:
      a, b = self._get_bounds(ts)
      window_size = b - a + 1
  
      if window_size <= 0:
          return np.array([], dtype=int)
  
      self.n += 1
      self.total_length += window_size
      avg_length = self.total_length / self.n
  
      if avg_length <= 0:
          return np.array([], dtype=int)
  
      p = self.num_instances / avg_length
      (indices,) = np.where(np.random.random_sample(window_size) < p)
      indices += a
      if len(indices) < self.min_instances:
          prefix = np.random.randint(
              a, b + 1, size=self.min_instances - len(indices)
          )
          return np.concatenate([prefix, indices])
  
      return indices
  
imports: from typing import Tuple
  import numpy
  from gluonts.dataset.stat import ScaleHistogram
  from gluonts.pydantic import BaseModel
label_desc: Use image node_id 1 for calling the ExpectedNumInstanceSampler obj's underlying member method code with example usage: obj.__call__(ts) and returns: indices, np, np, np