def _check_static_shape(expected_dims: Sequence[Union[int, tf.Tensor]],
                        actual_dims: Sequence[Union[int, tf.Tensor]],
                        tensor_name: Text, func_name: Text):
  """Checks the shape of a tensor argument, if it's possible statically."""
  for expected_dim, actual_dim in zip(expected_dims, actual_dims):
    if _is_dynamic(expected_dim) or _is_dynamic(actual_dim):
      continue
    if expected_dim != actual_dim:
      raise ValueError("Expected shape {} does not match actual shape {} "
                       "when checking contract for tensor `{}` in "
                       "function `{}`".format(
                           expected_dims, actual_dims, tensor_name,
                           func_name))
Checks the shape of a tensor argument, if it's possible statically.
language/canine/tensor_contracts.py