class_docstr: Sends a message to Telegram upon completion/failing of an experiment.
class_docstr_tok: ["Sends","a","message","to","Telegram","upon","completion\/failing","of","an","experiment","."]
code: def get_proxy_request(telegram_config):
      from telegram.utils.request import Request
  
      if telegram_config["proxy_url"].startswith("socks5"):
          urllib3_proxy_kwargs = dict()
          for key in ["username", "password"]:
              if key in telegram_config:
                  urllib3_proxy_kwargs[key] = telegram_config[key]
          return Request(
              proxy_url=telegram_config["proxy_url"],
              urllib3_proxy_kwargs=urllib3_proxy_kwargs,
          )
      elif telegram_config["proxy_url"].startswith("http"):
          cred_string = ""
          if "username" in telegram_config:
              cred_string += telegram_config["username"]
          if "password" in telegram_config:
              cred_string += ":" + telegram_config["password"]
          if len(cred_string) > 0:
              domain = (
                  telegram_config["proxy_url"]
                  .split("/")[-1]
                  .split("@")[-1]
              )
              cred_string += "@"
              proxy_url = "http://{}{}".format(cred_string, domain)
              return Request(proxy_url=proxy_url)
          else:
              return Request(proxy_url=telegram_config["proxy_url"])
      else:
          raise Exception(
              "Proxy URL should be in format "
              "PROTOCOL://PROXY_HOST[:PROXY_PORT].\n"
              "HTTP and Socks5 are supported."
          )
  
file_path: sacred/sacred/observers/telegram_obs.py
imports: from sacred.observers.base import RunObserver, td_format
  from sacred.config.config_files import load_config_file
  import logging
label_desc: Use image node_id 1 for calling the TelegramObserver obj's underlying member method code with example usage: obj.get_proxy_request(telegram_config) and returns: Request, Request, Request