def check(grad_honests, f_real, defense, factor=-16, negative=False, **kwargs):
  """ Check parameter validity for this attack template.
  Args:
    grad_honests Non-empty list of honest gradients
    f_real       Number of Byzantine gradients to generate
    defense      Aggregation rule in use to defeat
    ...          Ignored keyword-arguments
  Returns:
    Whether the given parameters are valid for this attack
  """
  if not isinstance(grad_honests, list) or len(grad_honests) == 0:
    return "Expected a non-empty list of honest gradients, got %r" % (grad_honests,)
  if not isinstance(f_real, int) or f_real < 0:
    return "Expected a non-negative number of Byzantine gradients to generate, got %r" % (f_real,)
  if not callable(defense):
    return "Expected a callable for the aggregation rule, got %r" % (defense,)
  if not ((isinstance(factor, float) and factor > 0) or (isinstance(factor, int) and factor != 0)):
    return "Expected a positive number or a negative integer for the attack factor, got %r" % (factor,)
  if not isinstance(negative, bool):
    return "Expected a boolean for optional parameter 'negative', got %r" % (negative,)