code: def main(
      session_url: Optional[str],
      instance_name: Optional[str] = None,
      commands: bool = False,
      filters: Optional[List[str]] = None,
  ):
      if filters and not commands:
          raise ValueError(
              "Must specify the command flag '-c' to use filter options '-f'."
          )
      random.seed(1235)
  
      logger = logging.getLogger("main")
      logger.setLevel(logging.INFO)
      handler = logging.StreamHandler()
      handler.setFormatter(
          logging.Formatter(
              "[%(levelname)s %(asctime)s] "
              "%(filename)s: %(lineno)d  "
              "%(message)s"
          )
      )
      logger.addHandler(handler)
  
      maybe_fetch_buildkite_token()
      repro = ReproSession(
          os.environ["BUILDKITE_TOKEN"],
          instance_name=instance_name,
          logger=logger,
      )
  
      session_url = session_url or click.prompt(
          "Please copy and paste the Buildkite job build URI here"
      )
  
      repro.set_session(session_url)
  
      repro.fetch_env_variables()
      repro.aws_start_instance()
      repro.aws_wait_for_instance()
  
      print("-" * 80)
      click.secho("Instance ID: ", nl=False)
      click.secho(repro.aws_instance_id, bold=True)
      click.secho("Instance IP: ", nl=False)
      click.secho(repro.aws_instance_ip, bold=True)
      print("-" * 80)
  
      logger.info(f"Instance IP: {repro.aws_instance_ip}")
  
      repro.prepare_instance()
      repro.docker_login()
  
      repro.fetch_buildkite_plugins()
      for plugin in repro.plugins:
          repro.install_buildkite_plugin(plugin)
  
      repro.execute_plugin_hook("dind", "pre-command")
      repro.execute_plugin_hook(
          "docker",
          "command",
          env={
              "BUILDKITE_COMMAND": "sleep infinity",
              "BUILDKITE_PLUGIN_DOCKER_TTY": "0",
              "BUILDKITE_PLUGIN_DOCKER_MOUNT_CHECKOUT": "0",
          },
          script_command=(
              "sed -E 's/"
              "docker run/"
              "docker run "
              "--cap-add=SYS_PTRACE "
              "--name ray_container "
              "-d/g' | "
              "bash -l"
          ),
      )
  
      repro.create_new_ssh_client()
  
      repro.print_buildkite_command()
  
      if commands:
          filters = filters or []
          repro.run_buildkite_command(command_filter=filters)
          repro.print_buildkite_command(skipped=True)
  
      repro.transfer_env_to_container()
  
      # Print once more before attaching
      click.secho("Instance ID: ", nl=False)
      click.secho(repro.aws_instance_id, bold=True)
      click.secho("Instance IP: ", nl=False)
      click.secho(repro.aws_instance_ip, bold=True)
      print("-" * 80)
  
      repro.attach_to_container()
  
      logger.info("You are now detached from the AWS instance.")
  
      if click.confirm("Stop AWS instance?", default=False):
          repro.aws_stop_instance()
      else:
          repro.print_stop_command()
  
imports: import base64
  import json
  import logging
  import os
  import random
  import re
  import shlex
  import subprocess
  import threading
  import time
  from numbers import Number
  from typing import Any, Dict, List, Optional, Callable
  import boto3
  import click
  import paramiko
  import yaml
  from pybuildkite.buildkite import Buildkite
label_desc: Use image node_id 5 for calling a global function with example usage: main(session_url, instance_name, commands, filters) without return types