code: def tune_params(scale, acc_rate):
      """
      Tunes the scaling parameter for the proposal distribution
      according to the acceptance rate over the last tune_interval:
  
      Rate  Variance adaptation
      ----  -------------------
      <0.001    x 0.1
      <0.05     x 0.5
      <0.2      x 0.9
      >0.5      x 1.1
      >0.75     x 2
      >0.95     x 10
  
      """
  
      # Switch statement
      if acc_rate < 0.001:
          # reduce by 90 percent
          scale *= 0.1
      elif acc_rate < 0.05:
          # reduce by 50 percent
          scale *= 0.5
      elif acc_rate < 0.2:
          # reduce by ten percent
          scale *= 0.9
      elif acc_rate > 0.95:
          # increase by factor of ten
          scale *= 10.0
      elif acc_rate > 0.75:
          # increase by double
          scale *= 2.0
      elif acc_rate > 0.5:
          # increase by ten percent
          scale *= 1.1
  
      return scale
  
imports: from __future__ import division
  import scipy.linalg
  import numpy
  import numpy.random
label_desc: Use image node_id 2 for calling a global function with example usage: tune_params(scale, acc_rate) and returns: scale