<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def downloads_per_year(collection, code, raw=False):
 """ This method retrieve the total of downloads per year. arguments collection: SciELO 3 letters Acronym code: (Journal ISSN, Issue PID, Article PID) return [ ("2017", "20101"), ("2016", "11201"), ("2015", "12311"), ] """


    tc = ThriftClient()

    body = {"query": {"filtered": {}}}

    fltr = {}

    query = {
        "query": {
            "bool": {
                "must": [
                    {
                        "match": {
                            "collection": collection
                        }
                    }
                ]
            }
        }
    }

    aggs = {
        "aggs": {
            "access_year": {
                "terms": {
                    "field": "access_year",
                    "size": 0,
                    "order": {
                        "_term": "asc"
                    }
                },
                "aggs": {
                    "access_total": {
                        "sum": {
                            "field": "access_total"
                        }
                    }
                }
            }
        }
    }

    body['query']['filtered'].update(fltr)
    body['query']['filtered'].update(query)
    body.update(aggs)

    code_type = _code_type(code)

    if code_type:
        query["query"]["bool"]["must"].append({
            "match": {
                code_type: code
            }
        })

    query_parameters = [
        ('size', '0')
    ]

    query_result = tc.search(json.dumps(body), query_parameters)

    return query_result if raw is True else _compute_downloads_per_year(query_result)