code: def connect_paste(
      button,
      paste_fields,
      input_comp,
      override_settings_component,
      tabname,
  ):
      def paste_func(prompt):
          if not prompt and not shared.cmd_opts.hide_ui_dir_config:
              filename = os.path.join(data_path, "params.txt")
              if os.path.exists(filename):
                  with open(filename, "r", encoding="utf8") as file:
                      prompt = file.read()
  
          params = parse_generation_parameters(prompt)
          script_callbacks.infotext_pasted_callback(prompt, params)
          res = []
  
          for output, key in paste_fields:
              if callable(key):
                  v = key(params)
              else:
                  v = params.get(key, None)
  
              if v is None:
                  res.append(gr.update())
              elif isinstance(v, type_of_gr_update):
                  res.append(v)
              else:
                  try:
                      valtype = type(output.value)
  
                      if valtype == bool and v == "False":
                          val = False
                      else:
                          val = valtype(v)
  
                      res.append(gr.update(value=val))
                  except Exception:
                      res.append(gr.update())
  
          return res
  
      if override_settings_component is not None:
          already_handled_fields = {key: 1 for _, key in paste_fields}
  
          def paste_settings(params):
              vals = {}
  
              mapping = [
                  (info.infotext, k)
                  for k, info in shared.opts.data_labels.items()
                  if info.infotext
              ]
              for param_name, setting_name in (
                  mapping + infotext_to_setting_name_mapping
              ):
                  if param_name in already_handled_fields:
                      continue
  
                  v = params.get(param_name, None)
                  if v is None:
                      continue
  
                  if (
                      setting_name == "sd_model_checkpoint"
                      and shared.opts.disable_weights_auto_swap
                  ):
                      continue
  
                  v = shared.opts.cast_value(setting_name, v)
                  current_value = getattr(
                      shared.opts, setting_name, None
                  )
  
                  if v == current_value:
                      continue
  
                  vals[param_name] = v
  
              vals_pairs = [f"{k}: {v}" for k, v in vals.items()]
  
              return gr.Dropdown.update(
                  value=vals_pairs,
                  choices=vals_pairs,
                  visible=bool(vals_pairs),
              )
  
          paste_fields = paste_fields + [
              (override_settings_component, paste_settings)
          ]
  
      button.click(
          fn=paste_func,
          inputs=[input_comp],
          outputs=[x[0] for x in paste_fields],
          show_progress=False,
      )
      button.click(
          fn=None,
          _js=f"recalculate_prompts_{tabname}",
          inputs=[],
          outputs=[],
          show_progress=False,
      )
  
imports: from __future__ import annotations
  import base64
  import io
  import json
  import os
  import re
  import gradio
  from modules.paths import data_path
  from modules import shared, ui_tempdir, script_callbacks, processing
  from PIL import Image
label_desc: Use image node_id 14 for calling a global function with example usage: connect_paste(button, paste_fields, input_comp, override_settings_component, tabname) and returns: res, gr