code: def sample_all_priors(
      model: GPyTorchModel, max_retries: int = 100
  ) -> None:
      r"""Sample from hyperparameter priors (in-place).
  
      Args:
          model: A GPyTorchModel.
      """
      for (
          _,
          module,
          prior,
          closure,
          setting_closure,
      ) in model.named_priors():
          if setting_closure is None:
              raise RuntimeError(
                  "Must provide inverse transform to be able to sample from prior."
              )
          for i in range(max_retries):
              try:
                  setting_closure(
                      module, prior.sample(closure(module).shape)
                  )
                  break
              except NotImplementedError:
                  warn(
                      f"`rsample` not implemented for {type(prior)}. Skipping.",
                      BotorchWarning,
                  )
                  break
              except RuntimeError as e:
                  if "out of bounds of its current constraints" in str(
                      e
                  ):
                      if i == max_retries - 1:
                          raise RuntimeError(
                              "Failed to sample a feasible parameter value "
                              f"from the prior after {max_retries} attempts."
                          )
                  else:
                      raise e
  
file_path: botorch/botorch/optim/utils/model_utils.py
imports: from __future__ import annotations
  from re import Pattern
  from typing import Any, Callable, Dict, Iterator, NamedTuple, Optional, Tuple, Union
  from warnings import warn
  import torch
  from botorch.exceptions.warnings import BotorchWarning
  from botorch.models.gpytorch import GPyTorchModel
  from torch import Tensor
  from torch.nn import Module
  from torch.utils.data import DataLoader, TensorDataset
label_desc: Use image node_id 5 for calling a global function with example usage: sample_all_priors(model, max_retries) without return types