code: def perturbation(
      hyperparameter_type,
      value,
      resample_probablity,
      uv,
      ub,
      lv,
      lb,
      random_state,
  ):
      """
      Perturbation for hyperparameters
  
      Parameters
      ----------
      hyperparameter_type : str
          type of hyperparameter
      value : list
          parameters for sampling hyperparameter
      resample_probability : float
          probability for resampling
      uv : float/int
          upper value after perturbation
      ub : float/int
          upper bound
      lv : float/int
          lower value after perturbation
      lb : float/int
          lower bound
      random_state : RandomState
          random state
      """
      if random.random() < resample_probablity:
          if hyperparameter_type == "choice":
              return value.index(
                  nni.parameter_expressions.choice(value, random_state)
              )
          else:
              return getattr(
                  nni.parameter_expressions, hyperparameter_type
              )(*(value + [random_state]))
      else:
          if random.random() > 0.5:
              return min(uv, ub)
          else:
              return max(lv, lb)
  
imports: import copy
  import logging
  import os
  import random
  import numpy
  from schema import Schema, Optional
  import nni
  from nni import ClassArgsValidator
  import nni.parameter_expressions
  from nni.tuner import Tuner
  from nni.utils import OptimizeMode, extract_scalar_reward, split_index, json2parameter, json2space
label_desc: Use image node_id 1 for calling a global function with example usage: perturbation(hyperparameter_type, value, resample_probablity, uv, ub, lv, lb, random_state) and returns: value, getattr, min, max