code: def bool_applier(value_name: str):
      """
      Returns a function that applies the given value to the given value_name in opts.data.
      """
  
      def validate(value_name: str, value: str):
          assert value.lower() in [
              "true",
              "false",
          ], f"Value {value} for {value_name} must be either true or false"
  
      def apply_bool(p, x, xs):
          validate(value_name, x)
          value_boolean = x.lower() == "true"
          opts.data[value_name] = value_boolean
  
      return apply_bool
  
imports: from modules import scripts
  from modules.shared import opts
label_desc: Use image node_id 2 for calling a global function with example usage: bool_applier(value_name) and returns: apply_bool