def METHOD_NAME(pred):
  """Return the bool value for `pred`, or None if `pred` had a dynamic value.
  Arguments:
    pred: A scalar, either a Python bool or tensor.
  Returns:
    True or False if `pred` has a constant boolean value, None otherwise.
  Raises:
    TypeError: If `pred` is not a Tensor or bool.
  """
  if isinstance(pred, ops.Tensor):
    pred_value = tensor_util.constant_value(pred)
    # TODO(skyewm): consider folding this into tensor_util.constant_value.
    # pylint: disable=protected-access
    if pred_value is None:
      pred_value = c_api.TF_TryEvaluateConstant_wrapper(pred.graph._c_graph,
                                                        pred._as_tf_output())
    # pylint: enable=protected-access
  elif pred in {0, 1}:  # Accept 1/0 as valid boolean values
    pred_value = bool(pred)
  elif isinstance(pred, bool):
    pred_value = pred
  else:
    raise TypeError("`pred` must be a Tensor, or a Python bool, or 1 or 0. "
                    "Found instead: %s" % type(pred))
  return pred_value