dataclasses error when importing the library in python 3.11
NONE
I opened [this issue](https://github.com/python/cpython/issues/99401).
Python's maintainers say that the issue is caused by [this change](https://docs.python.org/3.11/whatsnew/3.11.html#dataclasses).
I believe adding a `__hash__` method to `datasets.utils.version.Version` should solve (at least partially) this issue.
2022-11-12T14:06:56Z
https://github.com/huggingface/datasets/issues/5230#issuecomment-1312487780
https://api.github.com/repos/huggingface/datasets/issues/5230
IC_kwDODunzps5OOvlk
https://api.github.com/repos/huggingface/datasets/issues/comments/1312487780/reactions
2022-11-12T14:06:56Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1312487780
https://avatars.githubusercontent.com/u/76044840?v=4
https://api.github.com/users/yonikremer/events{/privacy}
https://api.github.com/users/yonikremer/followers
https://api.github.com/users/yonikremer/following{/other_user}
https://api.github.com/users/yonikremer/gists{/gist_id}
https://github.com/yonikremer
yonikremer
MDQ6VXNlcjc2MDQ0ODQw
https://api.github.com/users/yonikremer/orgs
https://api.github.com/users/yonikremer/received_events
https://api.github.com/users/yonikremer/repos
https://api.github.com/users/yonikremer/starred{/owner}{/repo}
https://api.github.com/users/yonikremer/subscriptions
User
https://api.github.com/users/yonikremer
public
NONE
Has this been fixed? I am running into this issue now. 

If this has been fixed, could have a new release with this?

2022-11-14T20:50:50Z
https://github.com/huggingface/datasets/issues/5230#issuecomment-1314362943
https://api.github.com/repos/huggingface/datasets/issues/5230
IC_kwDODunzps5OV5Y_
https://api.github.com/repos/huggingface/datasets/issues/comments/1314362943/reactions
2022-11-14T20:51:44Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1314362943
https://avatars.githubusercontent.com/u/10637482?v=4
https://api.github.com/users/cossio/events{/privacy}
https://api.github.com/users/cossio/followers
https://api.github.com/users/cossio/following{/other_user}
https://api.github.com/users/cossio/gists{/gist_id}
https://github.com/cossio
cossio
MDQ6VXNlcjEwNjM3NDgy
https://api.github.com/users/cossio/orgs
https://api.github.com/users/cossio/received_events
https://api.github.com/users/cossio/repos
https://api.github.com/users/cossio/starred{/owner}{/repo}
https://api.github.com/users/cossio/subscriptions
User
https://api.github.com/users/cossio
public
NONE
Hi, I am getting error while training 

(tensorflow) C:\tensorflow\models\research\object_detection>python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
Traceback (most recent call last):
  File "C:\tensorflow\models\research\object_detection\train.py", line 54, in <module>
    from object_detection.legacy import trainer
  File "C:\tensorflow\models\research\object_detection\legacy\trainer.py", line 27, in <module>
    from object_detection.builders import optimizer_builder
  File "C:\tensorflow\models\research\object_detection\builders\optimizer_builder.py", line 25, in <module>
    from official.modeling.optimization import ema_optimizer
  File "C:\tensorflow\models\official\modeling\optimization\__init__.py", line 19, in <module>
    from official.modeling.optimization.configs.optimization_config import *
  File "C:\tensorflow\models\official\modeling\optimization\configs\optimization_config.py", line 31, in <module>
    @dataclasses.dataclass
     ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\x0133252\AppData\Local\anaconda3\envs\tensorflow\Lib\dataclasses.py", line 1223, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "C:\Users\x0133252\AppData\Local\anaconda3\envs\tensorflow\Lib\dataclasses.py", line 1213, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\x0133252\AppData\Local\anaconda3\envs\tensorflow\Lib\dataclasses.py", line 958, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\x0133252\AppData\Local\anaconda3\envs\tensorflow\Lib\dataclasses.py", line 815, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'official.modeling.optimization.configs.optimizer_config.SGDConfig'> for field sgd is not allowed: use default_factory
2023-05-09T12:17:27Z
https://github.com/huggingface/datasets/issues/5230#issuecomment-1540023403
https://api.github.com/repos/huggingface/datasets/issues/5230
IC_kwDODunzps5byuRr
https://api.github.com/repos/huggingface/datasets/issues/comments/1540023403/reactions
2023-05-09T12:17:27Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1540023403
https://avatars.githubusercontent.com/u/73299425?v=4
https://api.github.com/users/Jayanth1812/events{/privacy}
https://api.github.com/users/Jayanth1812/followers
https://api.github.com/users/Jayanth1812/following{/other_user}
https://api.github.com/users/Jayanth1812/gists{/gist_id}
https://github.com/Jayanth1812
Jayanth1812
MDQ6VXNlcjczMjk5NDI1
https://api.github.com/users/Jayanth1812/orgs
https://api.github.com/users/Jayanth1812/received_events
https://api.github.com/users/Jayanth1812/repos
https://api.github.com/users/Jayanth1812/starred{/owner}{/repo}
https://api.github.com/users/Jayanth1812/subscriptions
User
https://api.github.com/users/Jayanth1812
public
NONE
@Jayanth1812 and anyone else receiving a similar issue, it most likely has to do with your Python version. Downgrading to Python 3.9 works for me, but doing a downgrade might impact a lot of things. So to be safe and what worked for me was creating a new conda environment and following the installations here: https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html

And for Tensorflow GPU compatibility, after installing TensorFlow follow the instructions in section 4 'GPU Setup' in this document: https://www.tensorflow.org/install/pip
2023-05-23T21:39:42Z
https://github.com/huggingface/datasets/issues/5230#issuecomment-1560157857
https://api.github.com/repos/huggingface/datasets/issues/5230
IC_kwDODunzps5c_h6h
https://api.github.com/repos/huggingface/datasets/issues/comments/1560157857/reactions
2023-05-23T21:39:42Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1560157857
https://avatars.githubusercontent.com/u/21233839?v=4
https://api.github.com/users/hengfranklin/events{/privacy}
https://api.github.com/users/hengfranklin/followers
https://api.github.com/users/hengfranklin/following{/other_user}
https://api.github.com/users/hengfranklin/gists{/gist_id}
https://github.com/hengfranklin
hengfranklin
MDQ6VXNlcjIxMjMzODM5
https://api.github.com/users/hengfranklin/orgs
https://api.github.com/users/hengfranklin/received_events
https://api.github.com/users/hengfranklin/repos
https://api.github.com/users/hengfranklin/starred{/owner}{/repo}
https://api.github.com/users/hengfranklin/subscriptions
User
https://api.github.com/users/hengfranklin
public
MEMBER
@Jayanth1812, you can see in your error stack trace, that the error is caused by the `tensorflow` library, not by the `datasets` library. See:
```
File "C:\Users\x0133252\AppData\Local\anaconda3\envs\tensorflow\Lib\dataclasses.py"
```

You should open an issue in their repository instead: https://github.com/tensorflow/tensorflow 
2023-05-25T04:35:09Z
https://github.com/huggingface/datasets/issues/5230#issuecomment-1562254075
https://api.github.com/repos/huggingface/datasets/issues/5230
IC_kwDODunzps5dHhr7
https://api.github.com/repos/huggingface/datasets/issues/comments/1562254075/reactions
2023-05-25T04:37:05Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1562254075
https://avatars.githubusercontent.com/u/8515462?v=4
https://api.github.com/users/albertvillanova/events{/privacy}
https://api.github.com/users/albertvillanova/followers
https://api.github.com/users/albertvillanova/following{/other_user}
https://api.github.com/users/albertvillanova/gists{/gist_id}
https://github.com/albertvillanova
albertvillanova
MDQ6VXNlcjg1MTU0NjI=
https://api.github.com/users/albertvillanova/orgs
https://api.github.com/users/albertvillanova/received_events
https://api.github.com/users/albertvillanova/repos
https://api.github.com/users/albertvillanova/starred{/owner}{/repo}
https://api.github.com/users/albertvillanova/subscriptions
User
https://api.github.com/users/albertvillanova
public
### Describe the bug

When I import datasets using python 3.11 the dataclasses standard library raises the following error:
`ValueError: mutable default <class 'datasets.utils.version.Version'> for field version is not allowed: use default_factory`

When I tried to import the library using the following jupyter notebook:
```
%%bash
# create python 3.11 conda env
conda create --yes --quiet -n myenv -c conda-forge python=3.11
# activate is
source activate myenv
# install pyarrow
/opt/conda/envs/myenv/bin/python -m pip install --quiet --extra-index-url https://pypi.fury.io/arrow-nightlies/ \
    --prefer-binary --pre pyarrow
# install datasets
/opt/conda/envs/myenv/bin/python -m pip install --quiet datasets
```

```
# create a python file that only imports datasets
with open("import_datasets.py", 'w') as f:
    f.write("import datasets")
# run it with the env
!/opt/conda/envs/myenv/bin/python import_datasets.py
```

I get the following error:
```
Traceback (most recent call last):
  File "/kaggle/working/import_datasets.py", line 1, in <module>
    import datasets
  File "/opt/conda/envs/myenv/lib/python3.11/site-packages/datasets/__init__.py", line 45, in <module>
    from .builder import ArrowBasedBuilder, BeamBasedBuilder, BuilderConfig, DatasetBuilder, GeneratorBasedBuilder
  File "/opt/conda/envs/myenv/lib/python3.11/site-packages/datasets/builder.py", line 91, in <module>
    @dataclass
     ^^^^^^^^^
  File "/opt/conda/envs/myenv/lib/python3.11/dataclasses.py", line 1221, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "/opt/conda/envs/myenv/lib/python3.11/dataclasses.py", line 1211, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/myenv/lib/python3.11/dataclasses.py", line 959, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/myenv/lib/python3.11/dataclasses.py", line 816, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'datasets.utils.version.Version'> for field version is not allowed: use default_factory
```

This is probably due to one of the following changes in the [dataclasses standard library](https://docs.python.org/3/library/dataclasses.html) in version 3.11:

1. Changed in version 3.11: Instead of looking for and disallowing objects of type list, dict, or set, unhashable objects are now not allowed as default values. Unhashability is used to approximate mutability.

2. fields may optionally specify a default value, using normal Python syntax:

```
@dataclass
class C:
    a: int       # 'a' has no default value
    b: int = 0   # assign a default value for 'b'
In this example, both a and b will be included in the added __init__() method, which will be defined as:

def __init__(self, a: int, b: int = 0):
```

3. Changed in version 3.11: If a field name is already included in the __slots__ of a base class, it will not be included in the generated __slots__ to prevent [overriding them](https://docs.python.org/3/reference/datamodel.html#datamodel-note-slots). Therefore, do not use __slots__ to retrieve the field names of a dataclass. Use [fields()](https://docs.python.org/3/library/dataclasses.html#dataclasses.fields) instead. To be able to determine inherited slots, base class __slots__ may be any iterable, but not an iterator.

4. weakref_slot: If true (the default is False), add a slot named “__weakref__”, which is required to make an instance weakref-able. It is an error to specify weakref_slot=True without also specifying slots=True.
[TypeError](https://docs.python.org/3/library/exceptions.html#TypeError) will be raised if a field without a default value follows a field with a default value. This is true whether this occurs in a single class, or as a result of class inheritance.

### Steps to reproduce the bug

Steps to reproduce the behavior:

1. go to [the notebook in kaggle](https://www.kaggle.com/yonikremer/repreducing-issue)
2. rub both of the cells

### Expected behavior

I'm expecting no issues.
This error should not occur.

### Environment info

kaggle kernels, with default settings:
pin to original environment, no accelerator.