(_config, config_class)
| 510 | |
| 511 | # recursively get the correct config |
| 512 | def _get_exact_config(_config, config_class): |
| 513 | # TODO: we probably needs to make sure they are equal class, not just instance |
| 514 | if _config.__class__ == config_class: |
| 515 | return _config |
| 516 | |
| 517 | # TODO: T5Gemma2 has `encoder` and `decoder` instead `_config` |
| 518 | |
| 519 | # We consider both cases: real config or dict (for `FastSpeech2ConformerConfig`'s encoder/decoder config, which are only module config) |
| 520 | config_dict = _config.to_dict() if not isinstance(_config, dict) else _config |
| 521 | |
| 522 | keys = [x for x in config_dict.keys() if x.endswith("_config") or x in ["encoder", "decoder"]] |
| 523 | |
| 524 | # TODO: For `VibeVoiceAcousticTokenizer`, it doesn't have `encoder_config` or `decoder_config` when converted to dict |
| 525 | # but it has this properties. |
| 526 | if not isinstance(_config, dict): |
| 527 | for attr in dir(_config): |
| 528 | if attr.endswith("_config") or attr in ["encoder", "decoder"]: |
| 529 | # TODO: damm, we have some `get_text_config` (and maybe others) which is function!!! |
| 530 | # For property, it's not callable! |
| 531 | if callable(getattr(_config, attr, None)): |
| 532 | continue |
| 533 | |
| 534 | keys.append(attr) |
| 535 | |
| 536 | for key in keys: |
| 537 | sub_config = getattr(_config, key) if not isinstance(_config, dict) else _config[key] |
| 538 | if sub_config is not None: |
| 539 | # TODO: `VibeVoiceAcousticTokenizerEncoder/DecoderConfig` needs some protection!!! |
| 540 | if sub_config.__class__ == _config.__class__: |
| 541 | continue |
| 542 | maybe_config = _get_exact_config(sub_config, config_class) |
| 543 | if isinstance(maybe_config, config_class): |
| 544 | return maybe_config |
| 545 | |
| 546 | return _config |
| 547 | |
| 548 | |
| 549 | def _build_model_tester_and_get_config(tester_class, model_tester_kwargs, model_type): |
no test coverage detected