code: def _format_failed_profiler_command(
      cmd, profiler, stdout, stderr
  ) -> str:
      stderr_str = decode(stderr)
      extra_message = ""
  
      # If some sort of permission error returned, show a message about how
      # to set up permissions correctly.
      if "permission" in stderr_str.lower():
          set_chown_command = (
              DARWIN_SET_CHOWN_CMD.format(profiler=profiler)
              if sys.platform == "darwin"
              else LINUX_SET_CHOWN_CMD.format(profiler=profiler)
          )
          extra_message = PROFILER_PERMISSIONS_ERROR_MESSAGE.format(
              profiler=profiler, set_chown_command=set_chown_command
          )
  
      return f"""Failed to execute `{cmd}`.
  {extra_message}
  === stderr ===
  {decode(stderr)}
  
  === stdout ===
  {decode(stdout)}
  """
  
file_path: ray/python/ray/dashboard/modules/reporter/profile_manager.py
imports: import asyncio
  import shutil
  import subprocess
  import os
  import sys
  from pathlib import Path
  from typing import Union
  from datetime import datetime
  import logging
label_desc: Use image node_id 2 for calling a global function with example usage: _format_failed_profiler_command(cmd, profiler, stdout, stderr) and returns: str, cmd, str, extra_message, str, decode, str, decode, str