code: def _get_sample_generator(samples):
      
      if isinstance(samples, Mapping):
          def samples_generator():
              for ind in range(samples[list(samples.keys())[0]].shape[0]):
                  yield np.array([samples[s][ind, :] for s in sorted(samples)])
      elif isinstance(samples, np.ndarray):
          def samples_generator():
              for ind in range(samples.shape[0]):
                  yield samples[ind]
      else:
          samples_generator = samples
      return samples_generator
docs: Get a sample generator from the given polymorphic input.
  
      Args:
          samples (ndarray, dict or generator): either an matrix of shape (d, p, n) with d problems, p parameters and
              n samples, or a dictionary with for every parameter a matrix with shape (d, n) or, finally,
              a generator function that yields sample arrays of shape (p, n).
  
      Returns:
          generator: a generator that yields a matrix of size (p, n) for every problem in the input.