Replace assertion with ValueError exceptions in run_image_captioning_flax.py
# What does this PR do?

Replaces 4 `assert` with `ValueError` exeception in run_image_captioning_flax.py.
Co-author: @AdiaWu

Related to [#12789](https://github.com/huggingface/transformers/issues/12789).

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?

## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@sgugger
_The documentation is not available anymore as the PR was closed or merged._<|||||>Thanks, but the issue was intended for library code, not examples. Let's see if @sanchit-gandhi doesn't mind!<|||||>Thank you for your suggestions @sanchit-gandhi! @sgugger ahh I should have known that. I'll update the library code next time.

[Updated] @sanchit-gandhi  After incorporating the suggestions I ran into the failed CI tests below, which I'm not sure how to fix. I assume it has to do with missing some code reformatting. I tried running `make style` on the target folder and received the following output:

<img width="470" alt="Screen Shot 2022-11-22 at 4 05 56 PM" src="https://user-images.githubusercontent.com/54815905/203421123-e0a20022-f62e-4e78-a6dc-903a826cd6cf.png">

I'm also new to open source, but I'll look into this issue in the meantime. Would appreciate any of your inputs! Thanks.<|||||>Hey @katiele47, sorry for the late reply! 

Could you check that you've installed Transformers form source? https://huggingface.co/docs/transformers/pr_checks#checks-on-a-pull-request

You can make sure you've installed the dev version of transformers by uninstalling transformers then pip installing from within the transformers repo:
```
pip uninstall transformers
pip install -e .[dev]
```

You should then be able to run `make style` for code quality fixes!<|||||>Hello @katiele47, in my case, 

I used 
- `pip install black`
- `black [your filepath]`


and this enabled CircleCi to pass the code quality tests.

**Output**

![reformat output](https://user-images.githubusercontent.com/35699839/204171957-d8659cb6-963b-4f10-ae94-aec44a715817.png)
<|||||>Thank you so much for reviewing my change @sanchit-gandhi!