def METHOD_NAME(model_id, validator_data, need_defaults):
    model_file_lines = ['']
    model_file_lines.append("    @model_validator(mode='before')")
    model_file_lines.append('    def _initial_validation(cls, values):')
    model_file_lines.append(
        f"        return validation.core.initialize_config("
        f"getattr(validators, 'initialize_{model_id}', identity)(values))"
    )
    model_file_lines.append('')
    model_file_lines.append("    @field_validator('*', mode='before')")
    model_file_lines.append('    def _validate(cls, value, info):')
    model_file_lines.append('        field = cls.model_fields[info.field_name]')
    model_file_lines.append('        field_name = field.alias or info.field_name')
    model_file_lines.append("        if field_name in info.context['configured_fields']:")
    model_file_lines.append(
        f"            value = getattr(validators, f'{model_id}_{{info.field_name}}', identity)(value, field=field)"
    )
    for option_name, import_paths in sorted(validator_data):
        model_file_lines.append('')
        model_file_lines.append(f'            if info.field_name == {option_name!r}:')
        for import_path in import_paths:
            model_file_lines.append(f'                value = validation.{import_path}(value, field=field)')
    if need_defaults:
        model_file_lines.append('        else:')
        model_file_lines.append(
            f"            value = getattr(defaults, f'{model_id}_{{info.field_name}}', lambda: value)()"
        )
    model_file_lines.append('')
    model_file_lines.append('        return validation.utils.make_immutable(value)')
    model_file_lines.append('')
    model_file_lines.append("    @model_validator(mode='after')")
    model_file_lines.append('    def _final_validation(cls, model):')
    model_file_lines.append(
        f"        return validation.core.check_model(getattr(validators, 'check_{model_id}', identity)(model))"
    )
    return model_file_lines