code: def prepare_prior(prior, kind, auto_scale):
      """Helper function to correctly set default priors and auto scaling
  
      Parameters
      ----------
      prior : Prior or None
          The prior.
      kind : string
          Accepted values are: ``"intercept"``, ``"common"``, or ``"group_specific"``.
      auto_scale : bool
          Whether priors should be scaled or not. Defaults to ``True``.
  
      Returns
      -------
      prior : Prior
          The prior.
      """
      if prior is None:
          if auto_scale:
              prior = get_default_prior(kind)
          else:
              prior = get_default_prior(kind + "_flat")
      elif isinstance(prior, Prior):
          prior.auto_scale = False
      else:
          raise ValueError("'prior' must be instance of Prior or None.")
      return prior
  
imports: import formulae
  import numpy
  import xarray
  from bambi.defaults import get_default_prior
  from bambi.families import univariate, multivariate
  from bambi.priors import Prior
  from bambi.terms import CommonTerm, GroupSpecificTerm, HSGPTerm, OffsetTerm, ResponseTerm
  from bambi.utils import get_aliased_name, is_hsgp_term
label_desc: Use image node_id 1 for calling a global function with example usage: prepare_prior(prior, kind, auto_scale) and returns: prior