docstr: Adds a prior to the module. The prior can be accessed as an attribute using the given name.
  
  Args:
      name (str):
          The name of the prior
      prior (Prior):
          The prior to be registered`
      param_or_closure (string or callable):
          Either the name of the parameter, or a closure (which upon calling evalutes a function on
          the module instance and one or more parameters):
          single parameter without a transform: `.register_prior("foo_prior", foo_prior, "foo_param")`
          transform a single parameter (e.g. put a log-Normal prior on it):
          `.register_prior("foo_prior", NormalPrior(0, 1), lambda module: torch.log(module.foo_param))`
          function of multiple parameters:
          `.register_prior("foo2_prior", foo2_prior, lambda module: f(module.param1, module.param2)))`
      setting_closure (callable, optional):
          A function taking in the module instance and a tensor in (transformed) parameter space,
          initializing the internal parameter representation to the proper value by applying the
          inverse transform. Enables setting parametres directly in the transformed space, as well
          as sampling parameter values from priors (see `sample_from_prior`)
code: def register_prior(
      self, name, prior, param_or_closure, setting_closure=None
  ):
      """
      Adds a prior to the module. The prior can be accessed as an attribute using the given name.
  
      Args:
          name (str):
              The name of the prior
          prior (Prior):
              The prior to be registered`
          param_or_closure (string or callable):
              Either the name of the parameter, or a closure (which upon calling evalutes a function on
              the module instance and one or more parameters):
              single parameter without a transform: `.register_prior("foo_prior", foo_prior, "foo_param")`
              transform a single parameter (e.g. put a log-Normal prior on it):
              `.register_prior("foo_prior", NormalPrior(0, 1), lambda module: torch.log(module.foo_param))`
              function of multiple parameters:
              `.register_prior("foo2_prior", foo2_prior, lambda module: f(module.param1, module.param2)))`
          setting_closure (callable, optional):
              A function taking in the module instance and a tensor in (transformed) parameter space,
              initializing the internal parameter representation to the proper value by applying the
              inverse transform. Enables setting parametres directly in the transformed space, as well
              as sampling parameter values from priors (see `sample_from_prior`)
  
      """
      if isinstance(param_or_closure, str):
          if param_or_closure not in self._parameters and not hasattr(
              self, param_or_closure
          ):
              raise AttributeError(
                  "Unknown parameter {name} for {module}".format(
                      name=param_or_closure,
                      module=self.__class__.__name__,
                  )
                  + " Make sure the parameter is registered before registering a prior."
              )
  
          def closure(module):
              return getattr(module, param_or_closure)
  
          if setting_closure is not None:
              raise RuntimeError(
                  "Must specify a closure instead of a parameter name when providing setting_closure"
              )
  
          def setting_closure(module, val):
              return module.initialize(**{param_or_closure: val})
  
      else:
          if len(inspect.signature(param_or_closure).parameters) == 0:
              raise ValueError(
                  """As of version 1.4, `param_or_closure` must operate on a module instance. For example:
  
                      likelihood.noise_covar.register_prior(
                          "noise_std_prior",
                          gpytorch.priors.NormalPrior(0, 1),
                          lambda module: module.noise.sqrt()
                      )
                      """
              )
          if (
              inspect.isfunction(setting_closure)
              and len(inspect.signature(setting_closure).parameters) < 2
          ):
              raise ValueError(
                  """As of version 1.4, `setting_closure` must operate on a module instance and a tensor. For example:
  
                      kernel.register_prior(
                          "radius_prior",
                          gpytorch.priors.LogNormalPrior(0, 1),
                          lambda module: module.radius,
                          lambda module, value: m._set_radius(value),
                      )
                      """
              )
          closure = param_or_closure
  
      self.add_module(name, prior)
      self._priors[name] = (prior, closure, setting_closure)
  
imports: import copy
  import inspect
  import itertools
  import operator
  from collections import OrderedDict
  from typing import Union
  import torch
  from linear_operator.operators import LinearOperator
  from torch import nn, Tensor
  from torch.distributions import Distribution
  from .constraints import Interval
label_desc: Use image node_id 18 for calling the Module obj's underlying member method code with example usage: obj.register_prior(name, prior, param_or_closure, setting_closure) and returns: getattr, module