code: def run_agent(
      sweep_id,
      function=None,
      in_jupyter=None,
      entity=None,
      project=None,
      count=None,
  ):
      parts = dict(entity=entity, project=project, name=sweep_id)
      err = sweep_utils.parse_sweep_id(parts)
      if err:
          wandb.termerror(err)
          return
      entity = parts.get("entity") or entity
      project = parts.get("project") or project
      sweep_id = parts.get("name") or sweep_id
  
      if entity:
          wandb.env.set_entity(entity)
      if project:
          wandb.env.set_project(project)
      if sweep_id:
          # TODO(jhr): remove when jobspec is merged
          os.environ[wandb.env.SWEEP_ID] = sweep_id
      logger.setLevel(logging.DEBUG)
      ch = logging.StreamHandler()
      log_level = logging.DEBUG
      if in_jupyter:
          log_level = logging.ERROR
      ch.setLevel(log_level)
      formatter = logging.Formatter(
          "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
      )
      ch.setFormatter(formatter)
      try:
          logger.addHandler(ch)
  
          api = InternalApi()
          queue = multiprocessing.Queue()
          agent = Agent(
              api,
              queue,
              sweep_id=sweep_id,
              function=function,
              in_jupyter=in_jupyter,
              count=count,
          )
          agent.run()
      finally:
          # make sure we remove the logging handler (important for jupyter notebooks)
          logger.removeHandler(ch)
  
imports: import logging
  import multiprocessing
  import os
  import platform
  import queue
  import re
  import signal
  import socket
  import subprocess
  import sys
  import time
  import traceback
  from typing import Any, Dict, List
  import yaml
  import wandb
  from wandb import util, wandb_lib, wandb_sdk
  from wandb.agents.pyagent import pyagent
  from wandb.apis import InternalApi
  from wandb.sdk.launch.sweeps import utils
label_desc: Use image node_id 1 for calling a global function with example usage: run_agent(sweep_id, function, in_jupyter, entity, project, count) without return types