<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def query(self, query, max_results=None, timeout=0, dry_run=False, use_legacy_sql=None, external_udf_uris=None):
 """Submit a query to BigQuery. Parameters query : str BigQuery query string max_results : int, optional The maximum number of rows to return per page of results. timeout : float, optional How long to wait for the query to complete, in seconds before the request times out and returns. dry_run : bool, optional If True, the query isn't actually run. A valid query will return an empty response, while an invalid one will return the same error message it would if it wasn't a dry run. use_legacy_sql : bool, optional. Default True. If False, the query will use BigQuery's standard SQL (https://cloud.google.com/bigquery/sql-reference/) external_udf_uris : list, optional Contains external UDF URIs. If given, URIs must be Google Cloud Storage and have .js extensions. Returns ------- tuple (job id, query results) if the query completed. If dry_run is True, job id will be None and results will be empty if the query is valid or a ``dict`` containing the response if invalid. Raises ------ BigQueryTimeoutException on timeout """


        logger.debug('Executing query: %s' % query)

        query_data = {
            'query': query,
            'timeoutMs': timeout * 1000,
            'dryRun': dry_run,
            'maxResults': max_results
        }

        if use_legacy_sql is not None:
            query_data['useLegacySql'] = use_legacy_sql

        if external_udf_uris:
            query_data['userDefinedFunctionResources'] = \
                [ {'resourceUri': u} for u in external_udf_uris ]

        return self._submit_query_job(query_data)