code: def _render_template_crowd_html(
      task_template: CritiqueTaskTemplate,
  ) -> str:
      """Render the Crowd HTML for the template."""
      validation_crowd_html = textwrap.dedent(
          """\
          <script>
              // Validates that an option is selected for each radio group
              // because Mechanical Turk Crowd HTML does not do so automatically.
              // Source: https://stackoverflow.com/a/71064873
              function validateForm() {
                  var valid = true;
                  var radioGroups = document.querySelectorAll("crowd-radio-group");
                  for (var i = 0; i < radioGroups.length; i++) {
                      var validGroup = false;
                      var radioButtons = radioGroups[i].children;
                      for (var j = 0; j < radioButtons.length; j++) {
                          validGroup = validGroup || radioButtons[j].checked;
                      }
                      valid = valid && validGroup;
                  }
                  return valid;
              }
  
              window.onload = function() {
                  document.querySelector('crowd-form').onsubmit = function(e) {
                      if (!validateForm()) {
                          alert("Please answer all the questions in order to submit.");
                          e.preventDefault();
                      }
                  }
              }
          </script>"""
      )
  
      instructions_crowd_html = f"<div>{_format_template_tags(task_template.instructions)}</div>"
      questions_crowd_html = "\n".join(
          [
              _render_question_crowd_html(question)
              for question in task_template.questions
          ]
      )
      return textwrap.dedent(
          f"""\
          <script src="https://assets.crowd.aws/crowd-html-elements.js"></script>
          {_indent_to_level(validation_crowd_html, 2)}
          <crowd-form answer-format="flatten-objects">
              {_indent_to_level(instructions_crowd_html, 3)}
              {_indent_to_level(questions_crowd_html, 3)}
          </crowd-form>"""
      )
  
imports: import csv
  from datetime import datetime
  import os
  from threading import Lock
  from typing import Dict, List, Sequence
  import textwrap
  import re
  from helm.common.critique_request import CritiqueQuestionTemplate, CritiqueRequest, CritiqueTaskTemplate, QuestionType
  from helm.common.general import ensure_directory_exists
  from helm.common.hierarchical_logger import hlog
label_desc: Use image node_id 3 for calling a global function with example usage: _render_template_crowd_html(task_template) and returns: textwrap