def METHOD_NAME(
    self, pipeline: Dict[str, Any], tags: List[Dict[str, str]]
) -> Tuple[Dict[str, Any], List[Dict[str, str]]]:
    name = pipeline["name"]
    if name in self.pipelines:
        raise InvalidStructureException(
            f"A pipeline with the name '{name}' already exists in account '{self.account_id}'"
        )
    try:
        role = self.iam_backend.get_role_by_arn(pipeline["roleArn"])
        trust_policy_statements = json.loads(role.assume_role_policy_document)[
            "Statement"
        ]
        trusted_service_principals = [
            i["Principal"]["Service"] for i in trust_policy_statements
        ]
        if "codepipeline.amazonaws.com" not in trusted_service_principals:
            raise IAMNotFoundException("")
    except IAMNotFoundException:
        raise InvalidStructureException(
            f"CodePipeline is not authorized to perform AssumeRole on role {pipeline['roleArn']}"
        )
    if len(pipeline["stages"]) < 2:
        raise InvalidStructureException(
            "Pipeline has only 1 stage(s). There should be a minimum of 2 stages in a pipeline"
        )
    self.pipelines[pipeline["name"]] = CodePipeline(
        self.account_id, self.region_name, pipeline
    )
    if tags is not None:
        self.pipelines[pipeline["name"]].validate_tags(tags)
        new_tags = {tag["key"]: tag["value"] for tag in tags}
        self.pipelines[pipeline["name"]].tags.update(new_tags)
    else:
        tags = []
    return pipeline, sorted(tags, key=lambda i: i["key"])