def METHOD_NAME(pred):
    """Return the bool value for `pred`, or None if `pred` had a dynamic value.
    Args:
      pred: A scalar, either a Python bool or a TensorFlow boolean variable
        or tensor, or the Python integer 1 or 0.
    Returns:
      True or False if `pred` has a constant boolean value, None otherwise.
    Raises:
      TypeError: If `pred` is not a Variable, Tensor or bool, or Python
        integer 1 or 0.
    """
    if isinstance(pred, tf.Tensor):
        return tf.get_static_value(pred)
    if pred in {0, 1}:  # Accept 1/0 as valid boolean values
        return bool(pred)
    if isinstance(pred, bool):
        return pred
    if isinstance(pred, tf.Variable):
        return None
    raise TypeError(
        "`pred` must be a Tensor, or a Python bool, or 1 or 0. "
        f"Received: {type(pred)}"
    )