code: def check(self, outdata):
      template = self.template
      checks = self.checks
  
      lines = outdata.split(b"\n")
      tmpl_lines = template.split(b"\n")
  
      # Collect placeholders included in the template
      temps = {}
      for iline, tmpl_line in enumerate(tmpl_lines):
          for m in re.finditer(
              rb"{(?P<key>[_a-zA-Z0-9]+) *}", tmpl_line
          ):
              key = m.groupdict()["key"].decode("utf8")
              assert key not in temps
              temps[key] = (m, iline)
  
      # Keys of the placeholders and the checks must match.
      assert set(temps.keys()) == set(checks.keys())
  
      # Evaluate the checks
      for key, (m, iline) in temps.items():
          line = lines[iline]
          c = checks[key]
          typ, checkfunc = c
          i1, i2 = m.span()
          i2 = min(i2, len(line))
          s = line[i1:i2]
          if typ is float:
              value = float(s)
              if not checkfunc(value):
                  raise RuntimeError("Check fail: key={}".format(key))
          else:
              raise TypeError("Invalid check type: {}".format(typ))
  
imports: import contextlib
  import os
  import re
  import shutil
  import subprocess
  import sys
  import tempfile
label_desc: Use image node_id 2 for calling the TemplateOutputEvaluator obj's underlying member method code with example usage: obj.check(outdata) without return types