<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_dataframe(self, bqstorage_client=None, dtypes=None, progress_bar_type=None):
 """Create a pandas DataFrame by loading all pages of a query. Args: bqstorage_client ( \ google.cloud.bigquery_storage_v1beta1.BigQueryStorageClient \ ):
 **Beta Feature** Optional. A BigQuery Storage API client. If supplied, use the faster BigQuery Storage API to fetch rows from BigQuery. This API is a billable API. This method requires the ``fastavro`` and ``google-cloud-bigquery-storage`` libraries. Reading from a specific partition or snapshot is not currently supported by this method. **Caution**: There is a known issue reading small anonymous query result tables with the BQ Storage API. When a problem is encountered reading a table, the tabledata.list method from the BigQuery API is used, instead. dtypes ( \ Map[str, Union[str, pandas.Series.dtype]] \ ):
 Optional. A dictionary of column names pandas ``dtype``s. The provided ``dtype`` is used when constructing the series for the column specified. Otherwise, the default pandas behavior is used. progress_bar_type (Optional[str]):
 If set, use the `tqdm <https://tqdm.github.io/>`_ library to display a progress bar while the data downloads. Install the ``tqdm`` package to use this feature. Possible values of ``progress_bar_type`` include: ``None`` No progress bar. ``'tqdm'`` Use the :func:`tqdm.tqdm` function to print a progress bar to :data:`sys.stderr`. ``'tqdm_notebook'`` Use the :func:`tqdm.tqdm_notebook` function to display a progress bar as a Jupyter notebook widget. ``'tqdm_gui'`` Use the :func:`tqdm.tqdm_gui` function to display a progress bar as a graphical dialog box. ..versionadded:: 1.11.0 Returns: pandas.DataFrame: A :class:`~pandas.DataFrame` populated with row data and column headers from the query results. The column headers are derived from the destination table's schema. Raises: ValueError: If the :mod:`pandas` library cannot be imported, or the :mod:`google.cloud.bigquery_storage_v1beta1` module is required but cannot be imported. """

        if pandas is None:
            raise ValueError(_NO_PANDAS_ERROR)
        if dtypes is None:
            dtypes = {}

        progress_bar = self._get_progress_bar(progress_bar_type)

        if bqstorage_client is not None:
            try:
                return self._to_dataframe_bqstorage(
                    bqstorage_client, dtypes, progress_bar=progress_bar
                )
            except google.api_core.exceptions.Forbidden:
                # Don't hide errors such as insufficient permissions to create
                # a read session, or the API is not enabled. Both of those are
                # clearly problems if the developer has explicitly asked for
                # BigQuery Storage API support.
                raise
            except google.api_core.exceptions.GoogleAPICallError:
                # There is a known issue with reading from small anonymous
                # query results tables, so some errors are expected. Rather
                # than throw those errors, try reading the DataFrame again, but
                # with the tabledata.list API.
                pass

        return self._to_dataframe_tabledata_list(dtypes, progress_bar=progress_bar)