code: def get_agent(request, monkeypatch):
      with monkeypatch.context() as m:
          if hasattr(request, "param"):
              delay = request.param
          else:
              delay = 0
  
          m.setenv(RAY_WORKER_TIMEOUT_S, delay)
          agent_port = new_port()
          stats_recorder = StatsRecorder()
          view_manager = ViewManager()
          stats_exporter = prometheus_exporter.new_stats_exporter(
              prometheus_exporter.Options(
                  namespace="test",
                  port=agent_port,
                  address="127.0.0.1",
              )
          )
          agent = MetricsAgent(
              view_manager, stats_recorder, stats_exporter
          )
          REGISTRY.register(agent.proxy_exporter_collector)
          yield agent, agent_port
          REGISTRY.unregister(agent.stats_exporter.collector)
          REGISTRY.unregister(agent.proxy_exporter_collector)
          execution_context.set_measure_to_view_map({})
  
imports: import os
  import time
  import sys
  import pytest
  import ray._private.prometheus_exporter
  from typing import List
  from opencensus.stats.view_manager import ViewManager
  from opencensus.stats.stats_recorder import StatsRecorder
  from opencensus.stats import execution_context
  from prometheus_client.core import REGISTRY
  from ray._private.metrics_agent import Gauge, MetricsAgent, Record, RAY_WORKER_TIMEOUT_S
  from ray._private.services import new_port
  from ray.core.generated.metrics_pb2 import Metric, MetricDescriptor, Point, LabelKey, TimeSeries, LabelValue
  from ray._raylet import WorkerID
  from ray._private.test_utils import fetch_prometheus_metrics, fetch_raw_prometheus, wait_for_condition
label_desc: Use image node_id 6 for calling a global function with example usage: get_agent(request, monkeypatch) without return types