code: def _stats_to_text(stats: List[CacheStat]) -> str:
      metric_type = "# TYPE cache_memory_bytes gauge"
      metric_unit = "# UNIT cache_memory_bytes bytes"
      metric_help = "# HELP Total memory consumed by a cache."
      openmetrics_eof = "# EOF\n"
  
      # Format: header, stats, EOF
      result = [metric_type, metric_unit, metric_help]
      result.extend(stat.to_metric_str() for stat in stats)
      result.append(openmetrics_eof)
  
      return "\n".join(result)
  
file_path: streamlit/lib/streamlit/web/server/stats_request_handler.py
imports: from typing import List
  import tornado.web
  from streamlit.proto.openmetrics_data_model_pb2 import GAUGE
  from streamlit.proto.openmetrics_data_model_pb2 import MetricSet
  from streamlit.runtime.stats import CacheStat, StatsManager
  from streamlit.web.server.server_util import emit_endpoint_deprecation_notice
label_desc: Use image node_id 5 for calling the StatsRequestHandler obj's underlying member method code with example usage: obj._stats_to_text(stats) and returns: str