<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def clean_operations(operations, openapi_major_version):
 """Ensure that all parameters with "in" equal to "path" are also required as required by the OpenAPI specification, as well as normalizing any references to global parameters. Also checks for invalid HTTP methods. See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#parameterObject. :param dict operations: Dict mapping status codes to operations :param int openapi_major_version: The major version of the OpenAPI standard to use. Supported values are 2 and 3. """

    invalid = {
        key
        for key in set(iterkeys(operations)) - set(VALID_METHODS[openapi_major_version])
        if not key.startswith("x-")
    }
    if invalid:
        raise APISpecError(
            "One or more HTTP methods are invalid: {}".format(", ".join(invalid))
        )

    def get_ref(obj_type, obj, openapi_major_version):
        """Return object or rererence

        If obj is a dict, it is assumed to be a complete description and it is returned as is.
        Otherwise, it is assumed to be a reference name as string and the corresponding $ref
        string is returned.

        :param str obj_type: "parameter" or "response"
        :param dict|str obj: parameter or response in dict form or as ref_id string
        :param int openapi_major_version: The major version of the OpenAPI standard
        """
        if isinstance(obj, dict):
            return obj
        return build_reference(obj_type, openapi_major_version, obj)

    for operation in (operations or {}).values():
        if "parameters" in operation:
            parameters = operation["parameters"]
            for parameter in parameters:
                if (
                    isinstance(parameter, dict)
                    and "in" in parameter
                    and parameter["in"] == "path"
                ):
                    parameter["required"] = True
            operation["parameters"] = [
                get_ref("parameter", p, openapi_major_version) for p in parameters
            ]
        if "responses" in operation:
            responses = OrderedDict()
            for code, response in iteritems(operation["responses"]):
                try:
                    code = int(code)  # handles IntEnums like http.HTTPStatus
                except (TypeError, ValueError):
                    if openapi_major_version < 3:
                        warnings.warn("Non-integer code not allowed in OpenAPI < 3")

                responses[str(code)] = get_ref(
                    "response", response, openapi_major_version
                )
            operation["responses"] = responses