code: def form_node(cls):
      
      assert issubclass(cls, FormNode)
      res = attrs(init=False, slots=True)(cls)
      res._args = []
      res._required_args = 0
      res._rest_arg = None
      state = _FormArgMode.REQUIRED
      for field in fields(res):
          if 'arg_mode' in field.metadata:
              if state is _FormArgMode.REST:
                  raise RuntimeError('rest argument must be last')
              if field.metadata['arg_mode'] is _FormArgMode.REQUIRED:
                  if state is _FormArgMode.OPTIONAL:
                      raise RuntimeError('required arg after optional arg')
                  res._args.append(field)
                  res._required_args += 1
              elif field.metadata['arg_mode'] is _FormArgMode.OPTIONAL:
                  state = _FormArgMode.OPTIONAL
                  res._args.append(field)
              elif field.metadata['arg_mode'] is _FormArgMode.REST:
                  state = _FormArgMode.REST
                  res._rest_arg = field
              else:
                  assert 0
      return res
docs: A class decorator to finalize fully derived FormNode subclasses.