test_pytorch_examples.py: cannot import name 'preserve_channel_dim' from 'albucore.utils'
Author: dvrogozh
Pull request: no
Labels: name: dependencies

Follow up from https://github.com/huggingface/transformers/pull/33485#issuecomment-2365429550. On https://github.com/huggingface/transformers/commit/78b2929c0554b79e0489b451ce4ece14d265ead2. Can't execute `test_pytorch_examples.py` due to the following error:

```
python3 -m pytest examples/pytorch/test_pytorch_examples.py
=================================================== test session starts ====================================================
platform linux -- Python 3.10.12, pytest-7.4.4, pluggy-1.5.0
rootdir: /home/dvrogozh/git/huggingface/transformers
configfile: pyproject.toml
plugins: pspec-0.0.4, timeout-2.3.1, hypothesis-6.112.1, xdist-3.6.1, rich-0.1.1, dash-2.18.1, cov-5.0.0, typeguard-4.3.0
collected 0 items / 1 error

========================================================== ERRORS ==========================================================
________________________________ ERROR collecting examples/pytorch/test_pytorch_examples.py ________________________________
ImportError while importing test module '/home/dvrogozh/git/huggingface/transformers/examples/pytorch/test_pytorch_examples.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
examples/pytorch/test_pytorch_examples.py:64: in <module>
    import run_instance_segmentation
examples/pytorch/instance-segmentation/run_instance_segmentation.py:25: in <module>
    import albumentations as A
../../../pytorch.xpu/lib/python3.10/site-packages/albumentations/__init__.py:6: in <module>
    from .augmentations import *
../../../pytorch.xpu/lib/python3.10/site-packages/albumentations/augmentations/__init__.py:1: in <module>
    from .blur.functional import *
../../../pytorch.xpu/lib/python3.10/site-packages/albumentations/augmentations/blur/__init__.py:1: in <module>
    from .functional import *
../../../pytorch.xpu/lib/python3.10/site-packages/albumentations/augmentations/blur/functional.py:9: in <module>
    from albucore.utils import clipped, maybe_process_in_chunks, preserve_channel_dim
E   ImportError: cannot import name 'preserve_channel_dim' from 'albucore.utils' (/home/dvrogozh/pytorch.xpu/lib/python3.10/site-packages/albucore/utils.py)
----------------------------------------------------- Captured stderr ------------------------------------------------------
2024-09-21 19:49:32.549825: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-09-21 19:49:32.552029: I external/local_tsl/tsl/cuda/cudart_stub.cc:31] Could not find cuda drivers on your machine, GPU will not be used.
2024-09-21 19:49:32.581133: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-09-21 19:49:32.581162: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-09-21 19:49:32.582216: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-09-21 19:49:32.588529: I external/local_tsl/tsl/cuda/cudart_stub.cc:31] Could not find cuda drivers on your machine, GPU will not be used.
2024-09-21 19:49:32.589056: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI AVX512_BF16 AVX_VNNI AMX_TILE AMX_INT8 AMX_BF16 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-09-21 19:49:33.234004: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
================================================= short test summary info ==================================================
ERROR examples/pytorch/test_pytorch_examples.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
===================================================== 1 error in 0.84s =====================================================
```

CC: @amyeroberts 

Comments:
Needs to change dependency in the [requirements.txt](https://github.com/huggingface/transformers/blob/78b2929c0554b79e0489b451ce4ece14d265ead2/examples/pytorch/_tests_requirements.txt), apparently it needs `albucore==0.0.16` based on https://github.com/ostris/ai-toolkit/issues/182#issuecomment-2364992905 👀 

I suppose should be fixed with the latest albumentations release 1.4.16

> I suppose should be fixed with the latest albumentations release 1.4.16

Yes. Test runs after upgrading albumentations to1.4.16.

@vasqu : is a bump in transformers's requirements.txt needed to `albumentations >= 1.4.16`? or this will be too restrictive.

@dvrogozh I don't think that it's necessary. Most prior versions also work, just that one minor version might be a bit broken and we have this issue to refer to in case.

Makes sense. I did push other PR yesterday and ci did pass, so I guess on ci side albumencores 1.4.16 was picked up successfully as well. I think we can close this issue then?

Wdyt @LysandreJik?

Fine to me to bump up the requirements to the latest patch!