code: def _stats_to_proto(stats: List[CacheStat]) -> MetricSetProto:
      metric_set = MetricSetProto()
  
      metric_family = metric_set.metric_families.add()
      metric_family.name = "cache_memory_bytes"
      metric_family.type = GAUGE
      metric_family.unit = "bytes"
      metric_family.help = "Total memory consumed by a cache."
  
      for stat in stats:
          metric_proto = metric_family.metrics.add()
          stat.marshall_metric_proto(metric_proto)
  
      metric_set = MetricSetProto()
      metric_set.metric_families.append(metric_family)
      return metric_set
  
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 6 for calling the StatsRequestHandler obj's underlying member method code with example usage: obj._stats_to_proto(stats) and returns: metric_set