def _check_preconditions(preconditions: Sequence[Union[Require, RequireTrue]],
                         args_dict: Dict[Text, Any],
                         named_dims: Dict[Text, Union[int, tf.Tensor]],
                         context: _Context) -> Sequence[tf.Operation]:
  """Check preconditions, returning any ops needed for dynamic checks."""
  precondition_ops = []
  for precondition in preconditions:
    if isinstance(precondition, Require):
      if precondition.tensor == RESULT:
        raise ValueError(
            "`Require` cannot use `RESULT`. Use `Ensure` instead.")
    ops = precondition.check(
        context,
        args_dict,
        named_dims,
        dynamic_asserts=_dynamic_asserts_enabled)
    if _dynamic_asserts_enabled:
      precondition_ops.extend(ops)
  return precondition_ops
Check preconditions, returning any ops needed for dynamic checks.
language/canine/tensor_contracts.py