class_docstr: Search implementation of :class:`~nni.nas.strategy.RandomOneShot`.
  
  Do not need extra preprocessing of dataloader.
  
  See Also
  --------
  nni.nas.strategy.RandomOneShot
  nni.nas.pytorch.oneshot.base_lightning.BaseOneShotLightningModule
code: def _repeat_until_valid(self, func: Callable[[], Sample]) -> Sample:
      self._sampling_attempt = 0
      while self._sampling_attempt < self._sampling_patience:
          self._sampling_attempt += 1
          sample = func()
          if self.filter is None or self.filter(sample):
              return sample
      raise RuntimeError(
          "Failed to sample a valid architecture after {} attempts.".format(
              self._sampling_patience
          )
      )
  
imports: from __future__ import annotations
  import warnings
  import logging
  from typing import Any, Callable, TYPE_CHECKING
  import pytorch_lightning
  import torch
  from nni.mutable import Sample
  from nni.nas.nn.pytorch import ModelSpace
  from .base_lightning import BaseOneShotLightningModule
  from .profiler import ProfilerPenalty, ExpectationProfilerPenalty, SampleProfilerPenalty
label_desc: Use image node_id 3 for calling the RandomSamplingLightningModule obj's underlying member method code with example usage: obj._repeat_until_valid(func) and returns: sample