code: def configure_component_memory_profiler(
      component_name: str,
      component_id: str,
      component_type: Optional[ServeComponentType] = None,
  ):
      """Configures the memory logger for this component.
  
      Does nothing if RAY_SERVE_ENABLE_MEMORY_PROFILING is disabled.
      """
  
      if RAY_SERVE_ENABLE_MEMORY_PROFILING:
          logger = logging.getLogger(SERVE_LOGGER_NAME)
  
          try:
              import memray
  
              logs_dir = get_serve_logs_dir()
              memray_file_name = get_component_log_file_name(
                  component_name=component_name,
                  component_id=component_id,
                  component_type=component_type,
                  suffix="_memray_0.bin",
              )
              memray_file_path = os.path.join(
                  logs_dir, memray_file_name
              )
  
              # If the actor restarted, memray requires a new file to start
              # tracking memory.
              restart_counter = 1
              while os.path.exists(memray_file_path):
                  memray_file_name = get_component_log_file_name(
                      component_name=component_name,
                      component_id=component_id,
                      component_type=component_type,
                      suffix=f"_memray_{restart_counter}.bin",
                  )
                  memray_file_path = os.path.join(
                      logs_dir, memray_file_name
                  )
                  restart_counter += 1
  
              # Memray usually tracks the memory usage of only a block of code
              # within a context manager. We explicitly call __enter__ here
              # instead of using a context manager to track memory usage across
              # all of the caller's code instead.
              memray.Tracker(
                  memray_file_path, native_traces=True
              ).__enter__()
  
              logger.info(
                  "RAY_SERVE_ENABLE_MEMORY_PROFILING is enabled. Started a "
                  "memray tracker on this actor. Tracker file located at "
                  f'"{memray_file_path}"'
              )
  
          except ImportError:
              logger.warning(
                  "RAY_SERVE_ENABLE_MEMORY_PROFILING is enabled, but memray "
                  "is not installed. No memory profiling is happening. "
                  "`pip install memray` to enable memory profiling."
              )
  
imports: import copy
  import json
  import logging
  import os
  from typing import Optional, Tuple
  import ray
  from ray.serve._private.common import ServeComponentType
  from ray.serve._private.constants import RAY_SERVE_ENABLE_CPU_PROFILING, RAY_SERVE_ENABLE_JSON_LOGGING, RAY_SERVE_ENABLE_MEMORY_PROFILING, SERVE_LOG_APPLICATION, SERVE_LOG_COMPONENT, SERVE_LOG_COMPONENT_ID, SERVE_LOG_DEPLOYMENT, SERVE_LOG_EXTRA_FIELDS, SERVE_LOG_LEVEL_NAME, SERVE_LOG_MESSAGE, SERVE_LOG_RECORD_FORMAT, SERVE_LOG_REPLICA, SERVE_LOG_REQUEST_ID, SERVE_LOG_ROUTE, SERVE_LOG_TIME, SERVE_LOGGER_NAME
  from ray.serve.schema import EncodingType, LoggingConfig
label_desc: Use image node_id 6 for calling a global function with example usage: configure_component_memory_profiler(component_name, component_id, component_type) without return types