code: def main(cpu_binding):
      if cpu_binding:
          runner_process.cpu_binding = True
      with gr.Blocks() as demo:
          with gr.Tab("optimize model"):
              Model = gr.Dropdown(
                  value="v2.1-base",
                  label="Model",
                  interactive=True,
                  choices=MODEL_CHOICES,
              )
              Device = gr.Radio(
                  value="CPU/iGPU FP16",
                  label="Device",
                  choices=DEVICE_CHOICES,
                  interactive=True,
              )
              local_model_path = gr.Textbox(
                  label="local model path (optional)", value=""
              )
              use_auth_token = gr.Textbox(
                  label="huggingface token (optional)", value=None
              )
  
              output_log = gr.Textbox(label="Log")
              opt_btn = gr.Button("Optimize Model")
  
          with gr.Tab("txt2img"):
              with gr.Row():
                  with gr.Column():
                      prompt = gr.Textbox(
                          label="Prompt",
                          value="A digital illustration of a medieval town, 4k, detailed, trending in art station, fantasy",
                      )
                      neg_prompt = gr.Textbox(label="Negative prompt")
                      with gr.Blocks():
                          scale = gr.Slider(
                              0,
                              10,
                              label="guidance scale",
                              value=7.5,
                              interactive=True,
                          )
                          steps = gr.Slider(
                              0,
                              100,
                              label="sampling steps",
                              value=10,
                              interactive=True,
                          )
                          scheduler = gr.Radio(
                              [
                                  "PNDMS",
                                  "DDIM",
                                  "Euler",
                                  "Euler A",
                                  "LMD",
                                  "DPM-Solver",
                              ],
                              label="scheduler",
                              value="DPM-Solver",
                          )
                          with gr.Row():
                              height = gr.Slider(
                                  1,
                                  1024,
                                  label="height",
                                  value=512,
                                  interactive=True,
                              )
                              width = gr.Slider(
                                  1,
                                  1024,
                                  label="width",
                                  value=512,
                                  interactive=True,
                              )
                          seed = gr.Number(
                              interactive=True,
                              precision=0,
                              label="seed",
                              value=-1,
                          )
  
                          with gr.Row():
                              optimization_methods = gr.Dropdown(
                                  label="switch option"
                              )
  
                  with gr.Column():
                      output = gr.Image(label="Image")
                      time_cost = gr.Text(label="Generation time (s)")
              gen_btn = gr.Button("Generate")
  
              gen_btn.click(
                  fn=pre_pipeline_process,
                  inputs=[
                      local_model_path,
                      optimization_methods,
                      scheduler,
                      seed,
                      prompt,
                      scale,
                      steps,
                      height,
                      width,
                      neg_prompt,
                  ],
                  outputs=[output, time_cost],
              )
          opt_btn.click(
              fn=pre_convert,
              inputs=[Model, Device, use_auth_token, local_model_path],
              outputs=[output_log, optimization_methods],
          )
          local_model_path.change(
              fn=update_options,
              inputs=[local_model_path],
              outputs=[optimization_methods],
          )
          demo.load(fn=update_options, outputs=[optimization_methods])
      if runner_process.cpu_binding:
          p = psutil.Process()
          p.cpu_affinity([0])
  
      # set this if browser is not at local
      # demo.launch(share=True, server_name="0.0.0.0")
  
      demo.launch(share=True)
  
file_path: BigDL/python/nano/client-application/StableDiffusion/launch.py
imports: import gradio
  import os
  import multiprocessing
  import time
  import psutil
  from stable_diffusion.runner import StableDiffusionRunner
  from stable_diffusion.converter import convert
  from stable_diffusion.pipelines import NanoStableDiffusionPipeline
  from stable_diffusion.utils import get_snapshot_dir_from_model_version
  from stable_diffusion import runner_process
  import click
label_desc: Use image node_id 8 for calling a global function with example usage: main(cpu_binding) without return types