code: def test_documents_and_requests(taskname, task_class):
      print("Evaluating task", taskname)
      task = task_class()
      fns = []
      if task.has_training_docs():
          fns.append(task.training_docs)
      if task.has_validation_docs():
          fns.append(task.validation_docs)
      # test doc might not have labels
      # if task.has_test_docs(): fns.append(task.test_docs)
  
      for fn in fns:
          # print(list(islice(fn(), 10)))
          for doc in islice(fn(), 10):
              txt = task.doc_to_text(doc)
              tgt = task.doc_to_target(doc)
  
              assert isinstance(txt, str)
              assert isinstance(tgt, str)
  
              # space convention
              # allow txt to have length 0 for perplexity-like tasks since the model tacks an <|endoftext|> on
              if len(txt) != 0:
                  assert txt[-1] != " "
                  assert tgt[0] == " " or txt[-1] == "\n"
  
              reqs = task.construct_requests(doc, txt)
  
              # construct_requests can return just one request
              if not isinstance(reqs, (list, tuple)):
                  reqs = [reqs]
  
              # todo: mock lm after refactoring evaluator.py to not be a mess
              for req in reqs:
                  assert isinstance(req, base.Request)
  
imports: import lm_eval.tasks
  import lm_eval.base
  import pytest
  from itertools import islice
label_desc: Use image node_id 2 for calling a global function with example usage: test_documents_and_requests(taskname, task_class) without return types