Repository: huggingface/diffusers

Issue:
`llm_guided_diffusion` example code gets `AttributeError: 'bool' object has no attribute '__module__'`
### Describe the bug

I simply followed the instructions [here](https://github.com/huggingface/diffusers/blob/main/examples/community/README.md#llm-grounded-diffusion) to try out the `llm_grounded_diffusion` pipeline and it doesn't work out of the box.

### Reproduction

Started with making sure I'm using main

```
poetry add git+https://github.com/huggingface/diffusers.git
```

Then copied the example code and ran:
```py
import torch
from diffusers import DiffusionPipeline

pipe = DiffusionPipeline.from_pretrained(
    "longlian/lmd_plus", 
    custom_pipeline="llm_grounded_diffusion",
    variant="fp16", torch_dtype=torch.float16
)
pipe.enable_model_cpu_offload()

# Generate directly from a text prompt and an LLM response
prompt = "a waterfall and a modern high speed train in a beautiful forest with fall foliage"
phrases, boxes, bg_prompt, neg_prompt = pipe.parse_llm_response("""
[('a waterfall', [71, 105, 148, 258]), ('a modern high speed train', [255, 223, 181, 149])]
Background prompt: A beautiful forest with fall foliage
Negative prompt:
""")

images = pipe(
    prompt=prompt,
    negative_prompt=neg_prompt,
    phrases=phrases,
    boxes=boxes,
    gligen_scheduled_sampling_beta=0.4,
    output_type="pil",
    num_inference_steps=50,
    lmd_guidance_kwargs={}
).images

images[0].save("./lmd_plus_generation.jpg")
``` 

### Logs

```shell
C:\Users\krist\AppData\Local\pypoetry\Cache\virtualenvs\testproject-cM1rhShM-py3.10\lib\site-packages\huggingface_hub\file_download.py:672: FutureWarning: 'cached_download' is the legacy way to download files from the HF hub, please consider upgrading to 'hf_hub_download'
  warnings.warn(
Loading pipeline components...:  29%|██▊       | 2/7 [00:00<00:00,  6.07it/s]C:\Users\krist\AppData\Local\pypoetry\Cache\virtualenvs\testproject-cM1rhShM-py3.10\lib\site-packages\transformers\models\clip\feature_extraction_clip.py:28: FutureWarning: The class CLIPFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please use CLIPImageProcessor instead.
  warnings.warn(
Loading pipeline components...:  86%|████████▌ | 6/7 [00:00<00:00,  9.93it/s]`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["id2label"]` will be overriden.
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["bos_token_id"]` will be overriden.
`text_config_dict` is provided which will be used to initialize `CLIPTextConfig`. The value `text_config["eos_token_id"]` will be overriden.
Loading pipeline components...: 100%|██████████| 7/7 [00:00<00:00,  7.78it/s]
Traceback (most recent call last):
  File "D:\GitHub\testproject\image_gen.py", line 19, in <module>
    pipe = DiffusionPipeline.from_pretrained(
  File "C:\Users\krist\AppData\Local\pypoetry\Cache\virtualenvs\testproject-cM1rhShM-py3.10\lib\site-packages\diffusers\pipelines\pipeline_utils.py", line 1357, in from_pretrained
    model = pipeline_class(**init_kwargs)
  File "C:\Users\krist\.cache\huggingface\modules\diffusers_modules\git\llm_grounded_diffusion.py", line 277, in __init__
    super().__init__(
  File "C:\Users\krist\AppData\Local\pypoetry\Cache\virtualenvs\testproject-cM1rhShM-py3.10\lib\site-packages\diffusers\pipelines\stable_diffusion\pipeline_stable_diffusion.py", line 236, in __init__
    self.register_modules(
  File "C:\Users\krist\AppData\Local\pypoetry\Cache\virtualenvs\testproject-cM1rhShM-py3.10\lib\site-packages\diffusers\pipelines\pipeline_utils.py", line 566, in register_modules
    library = not_compiled_module.__module__.split(".")[0]
AttributeError: 'bool' object has no attribute '__module__'. Did you mean: '__mod__'?
```


### System Info

- `diffusers` version: 0.24.0.dev0
- Platform: Windows-10-10.0.22621-SP0
- Python version: 3.10.2
- PyTorch version (GPU?): 1.13.0+cu117 (True)
- Huggingface_hub version: 0.19.4
- Transformers version: 4.35.2
- Accelerate version: 0.23.0
- xFormers version: not installed
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help?

_No response_


Discussion:
A bit of debugging on this, and it seems `LLMGroundedDiffusionPipeline` is supplying `requires_safety_checker` as a positional arg, which collided with `image_encoder` on `StableDiffusionPipeline`. `LLMGroundedDiffusionPipeline` should probably pass it as a kwarg instead

Resolving patch:
diff --git a/examples/community/llm_grounded_diffusion.py b/examples/community/llm_grounded_diffusion.py
--- a/examples/community/llm_grounded_diffusion.py
+++ b/examples/community/llm_grounded_diffusion.py
@@ -23,7 +23,7 @@
 
 import torch
 import torch.nn.functional as F
-from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
+from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, CLIPVisionModelWithProjection
 
 from diffusers.models import AutoencoderKL, UNet2DConditionModel
 from diffusers.models.attention import Attention, GatedSelfAttentionDense
@@ -272,10 +272,19 @@ def __init__(
         scheduler: KarrasDiffusionSchedulers,
         safety_checker: StableDiffusionSafetyChecker,
         feature_extractor: CLIPImageProcessor,
+        image_encoder: CLIPVisionModelWithProjection = None,
         requires_safety_checker: bool = True,
     ):
         super().__init__(
-            vae, text_encoder, tokenizer, unet, scheduler, safety_checker, feature_extractor, requires_safety_checker
+            vae,
+            text_encoder,
+            tokenizer,
+            unet,
+            scheduler,
+            safety_checker=safety_checker,
+            feature_extractor=feature_extractor,
+            image_encoder=image_encoder,
+            requires_safety_checker=requires_safety_checker,
         )
 
         self.register_attn_hooks(unet)


Test patch: