code: def run_txt2img(
      state,
      version,
      version_dict,
      is_legacy=False,
      return_latents=False,
      filter=None,
      stage2strength=None,
  ):
      if version.startswith("SDXL-base"):
          W, H = st.selectbox(
              "Resolution:", list(SD_XL_BASE_RATIOS.values()), 10
          )
      else:
          H = st.number_input(
              "H", value=version_dict["H"], min_value=64, max_value=2048
          )
          W = st.number_input(
              "W", value=version_dict["W"], min_value=64, max_value=2048
          )
      C = version_dict["C"]
      F = version_dict["f"]
  
      init_dict = {
          "orig_width": W,
          "orig_height": H,
          "target_width": W,
          "target_height": H,
      }
      value_dict = init_embedder_options(
          get_unique_embedder_keys_from_conditioner(
              state["model"].conditioner
          ),
          init_dict,
          prompt=prompt,
          negative_prompt=negative_prompt,
      )
      sampler, num_rows, num_cols = init_sampling(
          stage2strength=stage2strength
      )
      num_samples = num_rows * num_cols
  
      if st.button("Sample"):
          st.write(f"**Model I:** {version}")
          out = do_sample(
              state["model"],
              sampler,
              value_dict,
              num_samples,
              H,
              W,
              C,
              F,
              force_uc_zero_embeddings=["txt"] if not is_legacy else [],
              return_latents=return_latents,
              filter=filter,
          )
          return out
  
imports: from pytorch_lightning import seed_everything
  from scripts.demo.streamlit_helpers import *
label_desc: Use image node_id 2 for calling a global function with example usage: run_txt2img(state, version, version_dict, is_legacy, return_latents, filter, stage2strength) and returns: out