code: def download_button(
      object_to_download,
      download_filename,
      button_text,  # , pickle_it=False
  ):
      """
      Generates a link to download the given object_to_download.
  
      From: https://discuss.streamlit.io/t/a-download-button-with-custom-css/4220
  
      Params:
      ------
      object_to_download:  The object to be downloaded.
      download_filename (str): filename and extension of file. e.g. mydata.csv,
      some_txt_output.txt download_link_text (str): Text to display for download
      link.
      button_text (str): Text to display on download button (e.g. 'click here to download file')
      pickle_it (bool): If True, pickle file.
  
      Returns:
      -------
      (str): the anchor tag to download object_to_download
  
      Examples:
      --------
      download_link(your_df, 'YOUR_DF.csv', 'Click to download data!')
      download_link(your_str, 'YOUR_STRING.txt', 'Click to download text!')
  
      """
      # if pickle_it:
      #     try:
      #         object_to_download = pickle.dumps(object_to_download)
      #     except pickle.PicklingError as e:
      #         st.write(e)
      #         return None
  
      # else:
      #     if isinstance(object_to_download, bytes):
      #         pass
  
      #     elif isinstance(object_to_download, pd.DataFrame):
      #         object_to_download = object_to_download.to_csv(index=False)
  
      #     # Try JSON encode for everything else
      #     else:
      #         object_to_download = json.dumps(object_to_download)
  
      try:
          # some strings <-> bytes conversions necessary here
          b64 = base64.b64encode(object_to_download.encode()).decode()
      except AttributeError as e:
          b64 = base64.b64encode(object_to_download).decode()
  
      button_uuid = str(uuid.uuid4()).replace("-", "")
      button_id = re.sub("\d+", "", button_uuid)
  
      custom_css = f""" 
          <style>
              #{button_id} {{
                  display: inline-flex;
                  align-items: center;
                  justify-content: center;
                  background-color: rgb(255, 255, 255);
                  color: rgb(38, 39, 48);
                  padding: .25rem .75rem;
                  position: relative;
                  text-decoration: none;
                  border-radius: 4px;
                  border-width: 1px;
                  border-style: solid;
                  border-color: rgb(230, 234, 241);
                  border-image: initial;
              }} 
              #{button_id}:hover {{
                  border-color: rgb(246, 51, 102);
                  color: rgb(246, 51, 102);
              }}
              #{button_id}:active {{
                  box-shadow: none;
                  background-color: rgb(246, 51, 102);
                  color: white;
                  }}
          </style> """
  
      dl_link = (
          custom_css
          + f'<a download="{download_filename}" id="{button_id}" href="data:file/txt;base64,{b64}">{button_text}</a><br><br>'
      )
      # dl_link = f'<a download="{download_filename}" id="{button_id}" href="data:file/txt;base64,{b64}"><input type="button" kind="primary" value="{button_text}"></a><br></br>'
  
      st.markdown(dl_link, unsafe_allow_html=True)
  
file_path: traingenerator/app/utils.py
imports: import streamlit
  import pickle
  import pandas
  import json
  import base64
  import uuid
  import re
  import jupytext
  from bokeh.models.widgets import Div
  import math
  import importlib.util
label_desc: Use image node_id 6 for calling a global function with example usage: download_button(object_to_download, download_filename, button_text) without return types