code: def __generate(results):
          
          doc, tag, text = Doc().tagtext()
  
          # Counters for testsuite tag info
          count = 0
          fails = 0
          errors = 0
          skips = 0
  
          for result in results:
              # Loop through all results and count the ones that were not later retried.
              if result.passed() is False:
                  if result.retries_left > 0:
                      # This will appear in the list again, move on
                      continue
              count += 1
              if result.passed():
                  # Passed, no need to increment anything else
                  continue
              elif result.skipped():
                  skips += 1
              elif result.was_inconclusive():
                  errors += 1
              else:
                  fails += 1
  
          with tag('testsuite',
                   tests=str(count),
                   failures=str(fails),
                   errors=str(errors),
                   skipped=str(skips)):
              for result in results:
                  if result.passed() is False and result.retries_left > 0:
                      continue
                  class_name = result.get_tc_name()
                  models = result.get_dut_models()
                  if models:
                      class_name = class_name + "." + models
                  name = result.get_toolchain()
                  with tag('testcase', classname=class_name, name=name,
                           time=result.get_duration(seconds=True)):
                      if result.stdout:
                          with tag('system-out'):
                              text(result.stdout)
                      if result.passed():
                          continue
                      elif result.skipped():
                          with tag('skipped'):
                              text(result.skip_reason)
                      elif result.was_inconclusive():
                          with tag('error', message=hex_escape_str(result.fail_reason)):
                              text(result.stderr)
                      else:
                          with tag('failure', message=hex_escape_str(result.fail_reason)):
                              text(result.stderr)
          return indent(
              doc.getvalue(),
              indentation=' '*4
          )
docs: Static method which generates the Junit xml string from results
  
          :param results: Results as ResultList object.
          :return: Junit xml format string.