def evaluate(x, *args, **kwargs):
  """Evaluates a callable or constant value.

  Args:
    x: Either a callable or a constant value.
    *args: Positional arguments passed to `x` if `x` is callable.
    **kwargs: Keyword arguments passed to `x` if `x` is callable.

  Returns:
    Either the result of calling `x` if `x` is callable or else `x`.
  """
  return x(*args, **kwargs) if callable(x) else x