TFResNetForImageClassification fails with `save_pretrained()` when `saved_model` is True
transformersversion:4.21.0.dev0.Code:from transformers import AutoFeatureExtractor, TFResNetForImageClassification

temp_model_dir = "resnet"
model = TFResNetForImageClassification.from_pretrained("microsoft/resnet-50")
model.save_pretrained(temp_model_dir, saved_model=True)Error:---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-985e8a89bfb3> in <module>()
      2 temp_model_dir = "resnet"
      3 model = TFResNetForImageClassification.from_pretrained("microsoft/resnet-50")
----> 4 model.save_pretrained(temp_model_dir, saved_model=True)

3 frames
/usr/local/lib/python3.7/dist-packages/transformers/modeling_tf_utils.py in save_pretrained(self, save_directory, saved_model, version, push_to_hub, max_shard_size, **kwargs)
   1966         if saved_model:
   1967             saved_model_dir = os.path.join(save_directory, "saved_model", str(version))
-> 1968             self.save(saved_model_dir, include_optimizer=False, signatures=self.serving)
   1969             logger.info(f"Saved model created in {saved_model_dir}")
   1970 

/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py in error_handler(*args, **kwargs)
     65     except Exception as e:  # pylint: disable=broad-except
     66       filtered_tb = _process_traceback_frames(e.__traceback__)
---> 67       raise e.with_traceback(filtered_tb) from None
     68     finally:
     69       del filtered_tb

/usr/local/lib/python3.7/dist-packages/transformers/modeling_tf_utils.py in tf__serving(self, inputs)
      9                 do_return = False
     10                 retval_ = ag__.UndefinedReturnValue()
---> 11                 output = ag__.converted_call(ag__.ld(self).call, (ag__.ld(inputs),), None, fscope)
     12                 try:
     13                     do_return = True

/usr/local/lib/python3.7/dist-packages/transformers/modeling_tf_utils.py in tf__run_call_with_unpacked_inputs(self, *args, **kwargs)
     17                 try:
     18                     do_return = True
---> 19                     retval_ = ag__.converted_call(ag__.ld(func), (ag__.ld(self),), dict(**ag__.ld(unpacked_inputs)), fscope)
     20                 except:
     21                     do_return = False

TypeError: in user code:

    File "/usr/local/lib/python3.7/dist-packages/transformers/modeling_tf_utils.py", line 1063, in serving  *
        output = self.call(inputs)
    File "/usr/local/lib/python3.7/dist-packages/transformers/modeling_tf_utils.py", line 453, in run_call_with_unpacked_inputs  *
        return func(self, **unpacked_inputs)

    TypeError: tf__call() got an unexpected keyword argument 'input_ids'@amyeroberts@joaogante
2022-07-25T10:04:45Z
Thanks for flagging@sayakpaul!The error has been resolved with the merging of#18153and your posted snippet now runs on main.