code: def _run_apt_command(cmd, fatal=False):
      
      # Provide DEBIAN_FRONTEND=noninteractive if not present in the environment.
      cmd_env = {
          'DEBIAN_FRONTEND': os.environ.get('DEBIAN_FRONTEND', 'noninteractive')}
  
      if fatal:
          _run_with_retries(
              cmd, cmd_env=cmd_env, retry_exitcodes=(1, APT_NO_LOCK,),
              retry_message="Couldn't acquire DPKG lock")
      else:
          env = os.environ.copy()
          env.update(cmd_env)
          subprocess.call(cmd, env=env)
docs: Run an apt command with optional retries.
  
      :param: cmd: str: The apt command to run.
      :param: fatal: bool: Whether the command's output should be checked and
          retried.