inhomogeneous shape after 1 dimensions
Author: flckv
Pull request: no

### System Info


- `transformers` version: 4.30.0.dev0
- Platform: Linux-5.4.204-ql-generic-12.0-19-x86_64-with-glibc2.31
- Python version: 3.11.3
- Huggingface_hub version: 0.14.1
- Safetensors version: 0.3.1
- PyTorch version (GPU?): 2.0.1 (True)

### Who can help?

 @sanchit-gandhi @sgugger @muellerzr

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

Learned about audio classification: https://huggingface.co/tasks/audio-classification directed me to the steps:
Followed steps provided by doc:  https://huggingface.co/docs/transformers/v4.15.0/examples :


git clone https://github.com/huggingface/transformers
cd transformers
pip install .
cd /transformers/examples/pytorch/audio-classification
pip install -r requirements.txt


Followed steps provided by doc: https://github.com/huggingface/transformers/blob/main/examples/pytorch/audio-classification/README.md 

cd `transformers/examples/pytorch/audio-classification`

python `run_audio_classification.py \`
    --model_name_or_path facebook/wav2vec2-base \
    --dataset_name superb \
    --dataset_config_name ks \
    --output_dir wav2vec2-base-ft-keyword-spotting \
    --overwrite_output_dir \
    --remove_unused_columns False \
    --do_train \
    --do_eval \
    --fp16 \
    --learning_rate 3e-5 \
    --max_length_seconds 1 \
    --attention_mask False \
    --warmup_ratio 0.1 \
    --num_train_epochs 5 \
    --per_device_train_batch_size 32 \
    --gradient_accumulation_steps 4 \
    --per_device_eval_batch_size 32 \
    --dataloader_num_workers 4 \
    --logging_strategy steps \
    --logging_steps 10 \
    --evaluation_strategy epoch \
    --save_strategy epoch \
    --load_best_model_at_end True \
    --metric_for_best_model accuracy \
    --save_total_limit 3 \
    --seed 0 \
    --push_to_hub









### Errors:

(1) 

python3.11/site-packages/transformers/feature_extraction_utils.py", line 166, in convert_to_tensors
    tensor = as_tensor(value)
             ^^^^^^^^^^^^^^^^
**ValueError:** `setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (32,) + inhomogeneous part.
`

(2) 

python3.11/site-packages/transformers/feature_extraction_utils.py", line 172, in convert_to_tensors
    raise ValueError(
**ValueError:** `Unable to create tensor, you should probably activate padding with 'padding=True' to have batched tensors with the same length.`

### Expected behavior

get a fine-tuned model with the example model and dataset

Comments:
What version of NumPy are you using? If it's 1.24 can you downgrade it to 1.23 and try again?


@hollance, worked thanks

Alternatively, you can run `transformers` on main following the updates from #23162

When I downgrade numpy I gt a new error:

```
TypeError: `pad_width` must be of integral type.
```

```
TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/rave/mambaforge/envs/slickformer/lib/python3.9/site-packages/torch/utils/data/_utils/worker.py", line 308, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/rave/mambaforge/envs/slickformer/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 32, in fetch
    data.append(next(self.dataset_iter))
  File "/home/rave/mambaforge/envs/slickformer/lib/python3.9/site-packages/torch/utils/data/datapipes/_hook_iterator.py", line 144, in __next__
    return self._get_next()
  File "/home/rave/mambaforge/envs/slickformer/lib/python3.9/site-packages/torch/utils/data/datapipes/_hook_iterator.py", line 132, in _get_next
    result = next(self.iterator)
  File "/home/rave/mambaforge/envs/slickformer/lib/python3.9/site-packages/torch/utils/data/datapipes/_hook_iterator.py", line 215, in wrap_next
    result = next_func(*args, **kwargs)
  File "/home/rave/mambaforge/envs/slickformer/lib/python3.9/site-packages/torch/utils/data/datapipes/datapipe.py", line 369, in __next__
    return next(self._datapipe_iter)
  File "/home/rave/mambaforge/envs/slickformer/lib/python3.9/site-packages/torch/utils/data/datapipes/_hook_iterator.py", line 185, in wrap_generator
    response = gen.send(request)
  File "/home/rave/slickformer/ceruleanml/data_pipeline.py", line 321, in __iter__
    inputs = self.processor(images=[sample_dict['image']], segmentation_maps=[semantic_mask], task_inputs=["semantic"], reduce_labels=False, return_tensors="pt")
  File "/home/rave/mambaforge/envs/slickformer/lib/python3.9/site-packages/transformers/models/mask2former/image_processing_mask2former.py", line 542, in __call__
    return self.preprocess(images, segmentation_maps=segmentation_maps, **kwargs)
  File "/home/rave/mambaforge/envs/slickformer/lib/python3.9/site-packages/transformers/models/mask2former/image_processing_mask2former.py", line 718, in preprocess
    encoded_inputs = self.encode_inputs(
  File "/home/rave/mambaforge/envs/slickformer/lib/python3.9/site-packages/transformers/models/mask2former/image_processing_mask2former.py", line 870, in encode_inputs
    masks = [
  File "/home/rave/mambaforge/envs/slickformer/lib/python3.9/site-packages/transformers/models/mask2former/image_processing_mask2former.py", line 871, in <listcomp>
    self._pad_image(image=mask, output_size=pad_size, constant_values=ignore_index) for mask in masks
  File "/home/rave/mambaforge/envs/slickformer/lib/python3.9/site-packages/transformers/models/mask2former/image_processing_mask2former.py", line 740, in _pad_image
    padded_image = pad(
  File "/home/rave/mambaforge/envs/slickformer/lib/python3.9/site-packages/transformers/image_transforms.py", line 714, in pad
    image = np.pad(image, padding, mode="constant", constant_values=constant_values)
  File "<__array_function__ internals>", line 180, in pad
  File "/home/rave/mambaforge/envs/slickformer/lib/python3.9/site-packages/numpy/lib/arraypad.py", line 740, in pad
    raise TypeError('`pad_width` must be of integral type.')
TypeError: `pad_width` must be of integral type.
This exception is thrown by __iter__ of Mask2FormerSemanticProcessorDP(kwargs={}, sample_dicts=StackConvertLabelsToTensor)
```

@rbavery Could you open a new issue for this linking to this one (#23885)? It seems the error is arising from the use of the image transformers library, whereas this issue concerns audio models. It helps us keep track of what's been resolved and avoids Sanchit and Matthijs getting notifications whilst we try to solve this one :)