Repository: huggingface/transformers
Pull request: Fix bad tensor shape in failing Hubert test.

# What does this PR do?

Fixes breaking Hubert test: https://github.com/huggingface/transformers/actions/runs/16361063842/job/46229140250

cc @eustlb 

Redoing the integrations test would be nice but [original implementation](https://github.com/facebookresearch/textlesslib) is archived and installation/setup doesn't work because of configuration issues on their side that would take too much time... (see below traceback)

Otherwise fixed test is consistent with another one, see [here](https://github.com/huggingface/transformers/blob/561a79a2f4b5929f71266fb0ec1e2493c419d808/tests/models/hubert/test_modeling_hubert.py#L907)


```
Traceback (most recent call last):
  File "scripts/test_hubert.py", line 32, in <module>
    model = SpeechEncoder.by_name(dense_model_name='mhubert-base-25hz', quantizer_model_name='kmeans',
  File "/home/eric_bezzam/transformers/textlesslib/textless/data/speech_encoder.py", line 134, in by_name
    dense_model = dispatch_dense_model(dense_model_name)
  File "/home/eric_bezzam/transformers/textlesslib/textless/__init__.py", line 38, in dispatch_dense_model
    return model_class(checkpoint_path, layer=model_layer, **kwargs)
  File "/home/eric_bezzam/transformers/textlesslib/textless/data/hubert_feature_reader.py", line 28, in __init__
    self.load_checkpoint_()
  File "/home/eric_bezzam/transformers/textlesslib/textless_env/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
  File "/home/eric_bezzam/transformers/textlesslib/textless/data/hubert_feature_reader.py", line 32, in load_checkpoint_
    model, _, task = fairseq.checkpoint_utils.load_model_ensemble_and_task(
  File "/home/eric_bezzam/transformers/textlesslib/textless_env/lib/python3.8/site-packages/fairseq/checkpoint_utils.py", line 421, in load_model_ensemble_and_task
    task = tasks.setup_task(cfg.task)
  File "/home/eric_bezzam/transformers/textlesslib/textless_env/lib/python3.8/site-packages/fairseq/tasks/__init__.py", line 39, in setup_task
    cfg = merge_with_parent(dc(), cfg)
  File "/home/eric_bezzam/transformers/textlesslib/textless_env/lib/python3.8/site-packages/fairseq/dataclass/utils.py", line 483, in merge_with_parent
    merged_cfg = OmegaConf.merge(dc, cfg)
  File "/home/eric_bezzam/transformers/textlesslib/textless_env/lib/python3.8/site-packages/omegaconf/omegaconf.py", line 321, in merge
    target.merge_with(*others[1:])
  File "/home/eric_bezzam/transformers/textlesslib/textless_env/lib/python3.8/site-packages/omegaconf/basecontainer.py", line 331, in merge_with
    self._format_and_raise(key=None, value=None, cause=e)
  File "/home/eric_bezzam/transformers/textlesslib/textless_env/lib/python3.8/site-packages/omegaconf/base.py", line 95, in _format_and_raise
    format_and_raise(
  File "/home/eric_bezzam/transformers/textlesslib/textless_env/lib/python3.8/site-packages/omegaconf/_utils.py", line 629, in format_and_raise
    _raise(ex, cause)
  File "/home/eric_bezzam/transformers/textlesslib/textless_env/lib/python3.8/site-packages/omegaconf/_utils.py", line 610, in _raise
    raise ex  # set end OC_CAUSE=1 for full backtrace
  File "/home/eric_bezzam/transformers/textlesslib/textless_env/lib/python3.8/site-packages/omegaconf/basecontainer.py", line 329, in merge_with
    self._merge_with(*others)
  File "/home/eric_bezzam/transformers/textlesslib/textless_env/lib/python3.8/site-packages/omegaconf/basecontainer.py", line 347, in _merge_with
    BaseContainer._map_merge(self, other)
  File "/home/eric_bezzam/transformers/textlesslib/textless_env/lib/python3.8/site-packages/omegaconf/basecontainer.py", line 305, in _map_merge
    dest._format_and_raise(key=key, value=src_value, cause=e)
  File "/home/eric_bezzam/transformers/textlesslib/textless_env/lib/python3.8/site-packages/omegaconf/base.py", line 95, in _format_and_raise
    format_and_raise(
  File "/home/eric_bezzam/transformers/textlesslib/textless_env/lib/python3.8/site-packages/omegaconf/_utils.py", line 694, in format_and_raise
    _raise(ex, cause)
  File "/home/eric_bezzam/transformers/textlesslib/textless_env/lib/python3.8/site-packages/omegaconf/_utils.py", line 610, in _raise
    raise ex  # set end OC_CAUSE=1 for full backtrace
omegaconf.errors.ValidationError: Value '50.0' could not be converted to Integer
	full_key: label_rate
	reference_type=Optional[HubertPretrainingConfig]
	object_type=HubertPretrainingConfig
```





Changed files:
filename: tests/models/hubert/test_modeling_hubert.py
patch: @@ -962,19 +962,23 @@ def test_inference_hubert_25hz(self):
         # model(wav)['dense']
         expected_outputs_first = torch.tensor(
             [
-                [0.0267, 0.1776, -0.1706, -0.4559],
-                [-0.2430, -0.2943, -0.1864, -0.1187],
-                [-0.1812, -0.4239, -0.1916, -0.0858],
-                [-0.1495, -0.4758, -0.4036, 0.0302],
+                [
+                    [0.0267, 0.1776, -0.1706, -0.4559],
+                    [-0.2430, -0.2943, -0.1864, -0.1187],
+                    [-0.1812, -0.4239, -0.1916, -0.0858],
+                    [-0.1495, -0.4758, -0.4036, 0.0302],
+                ]
             ],
             device=torch_device,
         )
         expected_outputs_last = torch.tensor(
             [
-                [0.3366, -0.2734, -0.1415, -0.3055],
-                [0.2329, -0.3580, -0.1421, -0.3197],
-                [0.1631, -0.4301, -0.1965, -0.2956],
-                [0.3342, -0.2185, -0.2253, -0.2363],
+                [
+                    [0.3366, -0.2734, -0.1415, -0.3055],
+                    [0.2329, -0.3580, -0.1421, -0.3197],
+                    [0.1631, -0.4301, -0.1965, -0.2956],
+                    [0.3342, -0.2185, -0.2253, -0.2363],
+                ]
             ],
             device=torch_device,
         )