<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def validate(self, expectations_config=None, evaluation_parameters=None, catch_exceptions=True, result_format=None, only_return_failures=False):
 """Generates a JSON-formatted report describing the outcome of all expectations. Use the default expectations_config=None to validate the expectations config associated with the DataAsset. Args: expectations_config (json or None):
 \ If None, uses the expectations config generated with the DataAsset during the current session. \ If a JSON file, validates those expectations. evaluation_parameters (dict or None):
 \ If None, uses the evaluation_paramters from the expectations_config provided or as part of the data_asset. If a dict, uses the evaluation parameters in the dictionary. catch_exceptions (boolean):
 \ If True, exceptions raised by tests will not end validation and will be described in the returned report. result_format (string or None):
 \ If None, uses the default value ('BASIC' or as specified). \ If string, the returned expectation output follows the specified format ('BOOLEAN_ONLY','BASIC', etc.). include_config (boolean):
 \ If True, the returned results include the config information associated with each expectation, if \ it exists. only_return_failures (boolean):
 \ If True, expectation results are only returned when ``success = False`` \ Returns: A JSON-formatted dictionary containing a list of the validation results. \ An example of the returned format:: { "results": [ { "unexpected_list": [unexpected_value_1, unexpected_value_2], "expectation_type": "expect_*", "kwargs": { "column": "Column_Name", "output_format": "SUMMARY" }, "success": true, "raised_exception: false. "exception_traceback": null }, { }, ], "success": true, "statistics": { "evaluated_expectations": n, "successful_expectations": m, "unsuccessful_expectations": n - m, "success_percent": m / n } } Notes: If the configuration object was built with a different version of great expectations then the current environment. \ If no version was found in the configuration file. Raises: AttributeError - if 'catch_exceptions'=None and an expectation throws an AttributeError """


        results = []

        if expectations_config is None:
            expectations_config = self.get_expectations_config(
                discard_failed_expectations=False,
                discard_result_format_kwargs=False,
                discard_include_configs_kwargs=False,
                discard_catch_exceptions_kwargs=False,
            )
        elif isinstance(expectations_config, string_types):
            expectations_config = json.load(open(expectations_config, 'r'))

        if evaluation_parameters is None:
            # Use evaluation parameters from the (maybe provided) config
            if "evaluation_parameters" in expectations_config:
                evaluation_parameters = expectations_config["evaluation_parameters"]

        # Warn if our version is different from the version in the configuration
        try:
            if expectations_config['meta']['great_expectations.__version__'] != __version__:
                warnings.warn(
                    "WARNING: This configuration object was built using version %s of great_expectations, but is currently being valided by version %s." % (expectations_config['meta']['great_expectations.__version__'], __version__))
        except KeyError:
            warnings.warn(
                "WARNING: No great_expectations version found in configuration object.")

        for expectation in expectations_config['expectations']:

            try:
                expectation_method = getattr(
                    self, expectation['expectation_type'])

                if result_format is not None:
                    expectation['kwargs'].update({'result_format': result_format})

                # Counting the number of unexpected values can be expensive when there is a large
                # number of np.nan values.
                # This only happens on expect_column_values_to_not_be_null expectations.
                # Since there is no reason to look for most common unexpected values in this case,
                # we will instruct the result formatting method to skip this step.

                if expectation['expectation_type'] in ['expect_column_values_to_not_be_null',
                                                       'expect_column_values_to_be_null']:
                    expectation['kwargs']['result_format'] = parse_result_format(expectation['kwargs']['result_format'])
                    expectation['kwargs']['result_format']['partial_unexpected_count'] = 0

                # A missing parameter should raise a KeyError
                evaluation_args = self._build_evaluation_parameters(
                    expectation['kwargs'], evaluation_parameters)

                result = expectation_method(
                    catch_exceptions=catch_exceptions,
                    **evaluation_args
                )

            except Exception as err:
                if catch_exceptions:
                    raised_exception = True
                    exception_traceback = traceback.format_exc()

                    result = {
                        "success": False,
                        "exception_info": {
                            "raised_exception": raised_exception,
                            "exception_traceback": exception_traceback,
                            "exception_message": str(err)
                        }
                    }

                else:
                    raise(err)

            # if include_config:
            result["expectation_config"] = copy.deepcopy(expectation)

            # Add an empty exception_info object if no exception was caught
            if catch_exceptions and ('exception_info' not in result):
                result["exception_info"] = {
                    "raised_exception": False,
                    "exception_traceback": None,
                    "exception_message": None
                }

            results.append(result)

        statistics = _calc_validation_statistics(results)

        if only_return_failures:
            abbrev_results = []
            for exp in results:
                if exp["success"] == False:
                    abbrev_results.append(exp)
            results = abbrev_results

        result = {
            "results": results,
            "success": statistics.success,
            "statistics": {
                "evaluated_expectations": statistics.evaluated_expectations,
                "successful_expectations": statistics.successful_expectations,
                "unsuccessful_expectations": statistics.unsuccessful_expectations,
                "success_percent": statistics.success_percent,
            }
        }

        if evaluation_parameters is not None:
            result.update({"evaluation_parameters": evaluation_parameters})

        return result