code: def kubectl_exec(
      command: List[str],
      pod: str,
      namespace: str,
      container: Optional[str] = None,
  ) -> str:
      """kubectl exec the `command` in the given `pod` in the given `namespace`.
      If a `container` is specified, will specify that container for kubectl.
  
      Prints and return kubectl's output as a string.
      """
      container_option = ["-c", container] if container else []
      kubectl_exec_command = (
          ["kubectl", "exec", "-it", pod]
          + container_option
          + ["--"]
          + command
      )
      out = (
          subprocess.check_output(kubectl_exec_command).decode().strip()
      )
      # Print for debugging convenience.
      print(out)
      return out
  
imports: import atexit
  import contextlib
  import logging
  import pathlib
  import subprocess
  import tempfile
  import time
  from typing import Any, Dict, Generator, List, Optional
  import yaml
  import os
  import ray
  from ray.job_submission import JobStatus, JobSubmissionClient
label_desc: Use image node_id 11 for calling a global function with example usage: kubectl_exec(command, pod, namespace, container) and returns: out