def METHOD_NAME(formula, env, parser, evaluator):
    """
    Evaluates the nodata mask for a formula given a parser, a corresponding evaluator class, and an environment.
    The environment is a dict-like object (such as an `xarray.Dataset`) that maps variable names to values.
    """
    @lark.v_args(inline=True)
    class NodataMaskEvaluator(evaluator):
        def var_name(self, key):
            # pylint: disable=invalid-unary-operand-type
            return ~valid_data_mask(env[key.value])
    return NodataMaskEvaluator().transform(parser.parse(formula))