GitHub issue: Dataset not loading successfully.
Author: hi-sushanta (NONE)
State: closed | Created: 2023-12-29 01:35:47

### Describe the bug

When I run down the below code shows this error: AttributeError: module 'numpy' has no attribute '_no_nep50_warning'
I also added this issue in transformers library please check out: [link](https://github.com/huggingface/transformers/issues/28099)

### Steps to reproduce the bug

## Reproduction
Hi, please check this line of code, when I run Show attribute error.

```
from datasets import load_dataset
from transformers import WhisperProcessor, WhisperForConditionalGeneration

# Select an audio file and read it:
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
audio_sample = ds[0]["audio"]
waveform = audio_sample["array"]
sampling_rate = audio_sample["sampling_rate"]

# Load the Whisper model in Hugging Face format:
processor = WhisperProcessor.from_pretrained("openai/whisper-tiny.en")
model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny.en")

# Use the model and processor to transcribe the audio:
input_features = processor(
    waveform, sampling_rate=sampling_rate, return_tensors="pt"
).input_features

# Generate token ids
predicted_ids = model.generate(input_features)

# Decode token ids to text
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)

transcription[0]

```

**Attribute Error**
```
AttributeError                            Traceback (most recent call last)
Cell In[9], line 6
      4 # Select an audio file and read it:
      5 ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
----> 6 audio_sample = ds[0]["audio"]
      7 waveform = audio_sample["array"]
      8 sampling_rate = audio_sample["sampling_rate"]

File /opt/pytorch/lib/python3.8/site-packages/datasets/arrow_dataset.py:2795, in Dataset.__getitem__(self, key)
   2793 def __getitem__(self, key):  # noqa: F811
   2794     """Can be used to index columns (by string names) or rows (by integer index or iterable of indices or bools)."""
-> 2795     return self._getitem(key)

File /opt/pytorch/lib/python3.8/site-packages/datasets/arrow_dataset.py:2780, in Dataset._getitem(self, key, **kwargs)
   2778 formatter = get_formatter(format_type, features=self._info.features, **format_kwargs)
   2779 pa_subtable = query_table(self._data, key, indices=self._indices if self._indices is not None else None)
-> 2780 formatted_output = format_table(
   2781     pa_subtable, key, formatter=formatter, format_columns=format_columns, output_all_columns=output_all_columns
   2782 )
   2783 return formatted_output

File /opt/pytorch/lib/python3.8/site-packages/datasets/formatting/formatting.py:629, in format_table(table, key, formatter, format_columns, output_all_columns)
    627 python_formatter = PythonFormatter(features=formatter.features)
    628 if format_columns is None:
--> 629     return formatter(pa_table, query_type=query_type)
    630 elif query_type == "column":
    631     if key in format_columns:

File /opt/pytorch/lib/python3.8/site-packages/datasets/formatting/formatting.py:396, in Formatter.__call__(self, pa_table, query_type)
    394 def __call__(self, pa_table: pa.Table, query_type: str) -> Union[RowFormat, ColumnFormat, BatchFormat]:
    395     if query_type == "row":
--> 396         return self.format_row(pa_table)
    397     elif query_type == "column":
    398         return self.format_column(pa_table)

File /opt/pytorch/lib/python3.8/site-packages/datasets/formatting/formatting.py:437, in PythonFormatter.format_row(self, pa_table)
    435     return LazyRow(pa_table, self)
    436 row = self.python_arrow_extractor().extract_row(pa_table)
--> 437 row = self.python_features_decoder.decode_row(row)
    438 return row

File /opt/pytorch/lib/python3.8/site-packages/datasets/formatting/formatting.py:215, in PythonFeaturesDecoder.decode_row(self, row)
    214 def decode_row(self, row: dict) -> dict:
--> 215     return self.features.decode_example(row) if self.features else row

File /opt/pytorch/lib/python3.8/site-packages/datasets/features/features.py:1917, in Features.decode_example(self, example, token_per_repo_id)
   1903 def decode_example(self, example: dict, token_per_repo_id: Optional[Dict[str, Union[str, bool, None]]] = None):
   1904     """Decode example with custom feature decoding.
   1905 
   1906     Args:
   (...)
   1914         `dict[str, Any]`
   1915     """
-> 1917     return {
   1918         column_name: decode_nested_example(feature, value, token_per_repo_id=token_per_repo_id)
   1919         if self._column_requires_decoding[column_name]
   1920         else value
   1921         for column_name, (feature, value) in zip_dict(
   1922             {key: value for key, value in self.items() if key in example}, example
   1923         )
   1924     }

File /opt/pytorch/lib/python3.8/site-packages/datasets/features/features.py:1918, in <dictcomp>(.0)
   1903 def decode_example(self, example: dict, token_per_repo_id: Optional[Dict[str, Union[str, bool, None]]] = None):
   1904     """Decode example with custom feature decoding.
   1905 
   1906     Args:
   (...)
   1914         `dict[str, Any]`
   1915     """
   1917     return {
-> 1918         column_name: decode_nested_example(feature, value, token_per_repo_id=token_per_repo_id)
   1919         if self._column_requires_decoding[column_name]
   1920         else value
   1921         for column_name, (feature, value) in zip_dict(
   1922             {key: value for key, value in self.items() if key in example}, example
   1923         )
   1924     }

File /opt/pytorch/lib/python3.8/site-packages/datasets/features/features.py:1339, in decode_nested_example(schema, obj, token_per_repo_id)
   1336 elif isinstance(schema, (Audio, Image)):
   1337     # we pass the token to read and decode files from private repositories in streaming mode
   1338     if obj is not None and schema.decode:
-> 1339         return schema.decode_example(obj, token_per_repo_id=token_per_repo_id)
   1340 return obj

File /opt/pytorch/lib/python3.8/site-packages/datasets/features/audio.py:191, in Audio.decode_example(self, value, token_per_repo_id)
    189 array = array.T
    190 if self.mono:
--> 191     array = librosa.to_mono(array)
    192 if self.sampling_rate and self.sampling_rate != sampling_rate:
    193     array = librosa.resample(array, orig_sr=sampling_rate, target_sr=self.sampling_rate)

File /opt/pytorch/lib/python3.8/site-packages/lazy_loader/__init__.py:78, in attach.<locals>.__getattr__(name)
     76 submod_path = f"{package_name}.{attr_to_modules[name]}"
     77 submod = importlib.import_module(submod_path)
---> 78 attr = getattr(submod, name)
     80 # If the attribute lives in a file (module) with the same
     81 # name as the attribute, ensure that the attribute and *not*
     82 # the module is accessible on the package.
     83 if name == attr_to_modules[name]:

File /opt/pytorch/lib/python3.8/site-packages/lazy_loader/__init__.py:77, in attach.<locals>.__getattr__(name)
     75 elif name in attr_to_modules:
     76     submod_path = f"{package_name}.{attr_to_modules[name]}"
---> 77     submod = importlib.import_module(submod_path)
     78     attr = getattr(submod, name)
     80     # If the attribute lives in a file (module) with the same
     81     # name as the attribute, ensure that the attribute and *not*
     82     # the module is accessible on the package.

File /usr/lib/python3.8/importlib/__init__.py:127, in import_module(name, package)
    125             break
    126         level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1014, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:991, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:975, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:671, in _load_unlocked(spec)

File <frozen importlib._bootstrap_external>:848, in exec_module(self, module)

File <frozen importlib._bootstrap>:219, in _call_with_frames_removed(f, *args, **kwds)

File /opt/pytorch/lib/python3.8/site-packages/librosa/core/audio.py:13
     11 import audioread
     12 import numpy as np
---> 13 import scipy.signal
     14 import soxr
     15 import lazy_loader as lazy

File /opt/pytorch/lib/python3.8/site-packages/scipy/signal/__init__.py:323
    314 from ._spline import (  # noqa: F401
    315     cspline2d,
    316     qspline2d,
   (...)
    319     symiirorder2,
    320 )
    322 from ._bsplines import *
--> 323 from ._filter_design import *
    324 from ._fir_filter_design import *
    325 from ._ltisys import *

File /opt/pytorch/lib/python3.8/site-packages/scipy/signal/_filter_design.py:16
     13 from numpy.polynomial.polynomial import polyval as npp_polyval
     14 from numpy.polynomial.polynomial import polyvalfromroots
---> 16 from scipy import special, optimize, fft as sp_fft
     17 from scipy.special import comb
     18 from scipy._lib._util import float_factorial

File /opt/pytorch/lib/python3.8/site-packages/scipy/optimize/__init__.py:405
      1 """
      2 =====================================================
      3 Optimization and root finding (:mod:`scipy.optimize`)
   (...)
    401 
    402 """
    404 from ._optimize import *
--> 405 from ._minimize import *
    406 from ._root import *
    407 from ._root_scalar import *

File /opt/pytorch/lib/python3.8/site-packages/scipy/optimize/_minimize.py:26
     24 from ._trustregion_krylov import _minimize_trust_krylov
     25 from ._trustregion_exact import _minimize_trustregion_exact
---> 26 from ._trustregion_constr import _minimize_trustregion_constr
     28 # constrained minimization
     29 from ._lbfgsb_py import _minimize_lbfgsb

File /opt/pytorch/lib/python3.8/site-packages/scipy/optimize/_trustregion_constr/__init__.py:4
      1 """This module contains the equality constrained SQP solver."""
----> 4 from .minimize_trustregion_constr import _minimize_trustregion_constr
      6 __all__ = ['_minimize_trustregion_constr']

File /opt/pytorch/lib/python3.8/site-packages/scipy/optimize/_trustregion_constr/minimize_trustregion_constr.py:5
      3 from scipy.sparse.linalg import LinearOperator
      4 from .._differentiable_functions import VectorFunction
----> 5 from .._constraints import (
      6     NonlinearConstraint, LinearConstraint, PreparedConstraint, strict_bounds)
      7 from .._hessian_update_strategy import BFGS
      8 from .._optimize import OptimizeResult

File /opt/pytorch/lib/python3.8/site-packages/scipy/optimize/_constraints.py:8
      6 from ._optimize import OptimizeWarning
      7 from warnings import warn, catch_warnings, simplefilter
----> 8 from numpy.testing import suppress_warnings
      9 from scipy.sparse import issparse
     12 def _arr_to_scalar(x):
     13     # If x is a numpy array, return x.item().  This will
     14     # fail if the array has more than one element.

File /opt/pytorch/lib/python3.8/site-packages/numpy/testing/__init__.py:11
      8 from unittest import TestCase
     10 from . import _private
---> 11 from ._private.utils import *
     12 from ._private.utils import (_assert_valid_refcount, _gen_alignment_data)
     13 from ._private import extbuild, decorators as dec

File /opt/pytorch/lib/python3.8/site-packages/numpy/testing/_private/utils.py:480
    476         pprint.pprint(desired, msg)
    477         raise AssertionError(msg.getvalue())
--> 480 @np._no_nep50_warning()
    481 def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=True):
    482     """
    483     Raises an AssertionError if two items are not equal up to desired
    484     precision.
   (...)
    548 
    549     """
    550     __tracebackhide__ = True  # Hide traceback for py.test

File /opt/pytorch/lib/python3.8/site-packages/numpy/__init__.py:313, in __getattr__(attr)
    305     raise AttributeError(__former_attrs__[attr])
    307 # Importing Tester requires importing all of UnitTest which is not a
    308 # cheap import Since it is mainly used in test suits, we lazy import it
    309 # here to save on the order of 10 ms of import time for most users
    310 #
    311 # The previous way Tester was imported also had a side effect of adding
    312 # the full `numpy.testing` namespace
--> 313 if attr == 'testing':
    314     import numpy.testing as testing
    315     return testing

AttributeError: module 'numpy' has no attribute '_no_nep50_warning'

```

### Expected behavior

``` ' Mr. Quilter is the apostle of the middle classes, and we are glad to welcome his gospel.' ```

Also, make sure this script is provided for your official website so please update:
[script](https://huggingface.co/docs/transformers/model_doc/whisper)

### Environment info

**System Info**
* transformers -> 4.36.1
* datasets -> 2.15.0
* huggingface_hub -> 0.19.4
* python -> 3.8.10
* accelerate -> 0.25.0
* pytorch -> 2.0.1+cpu
* Using GPU in Script -> No