Repository: huggingface/diffusers
File: src/diffusers/models/modeling_utils.py (Python)

Code before:
            force_download (`bool`, *optional*, defaults to `False`):
                Whether or not to force the (re-)download of the model weights and configuration files, overriding the
                cached versions if they exist.
            proxies (`Dict[str, str]`, *optional*):
                A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128',
                'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request.
            output_loading_info (`bool`, *optional*, defaults to `False`):
                Whether or not to also return a dictionary containing missing keys, unexpected keys and error messages.
            local_files_only(`bool`, *optional*, defaults to `False`):
                Whether to only load local model weights and configuration files or not. If set to `True`, the model
                won't be downloaded from the Hub.
            token (`str` or *bool*, *optional*):
                The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from
                `diffusers-cli login` (stored in `~/.huggingface`) is used.
            revision (`str`, *optional*, defaults to `"main"`):
                The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier
                allowed by Git.
            from_flax (`bool`, *optional*, defaults to `False`):
                Load the model weights from a Flax checkpoint save file.
            subfolder (`str`, *optional*, defaults to `""`):
                The subfolder location of a model file within a larger model repository on the Hub or locally.
            mirror (`str`, *optional*):
                Mirror source to resolve accessibility issues if you're downloading a model in China. We do not
                guarantee the timeliness or safety of the source, and you should refer to the mirror site for more
                information.
            device_map (`Union[int, str, torch.Device]` or `Dict[str, Union[int, str, torch.device]]`, *optional*):
                A map that specifies where each submodule should go. It doesn't need to be defined for each
                parameter/buffer name; once a given module name is inside, every submodule of it will be sent to the
                same device. Defaults to `None`, meaning that the model will be loaded on CPU.

                Examples:

                ```py
                >>> from diffusers import AutoModel
                >>> import torch

                >>> # This works.
                >>> model = AutoModel.from_pretrained(
                ...     "stabilityai/stable-diffusion-xl-base-1.0", subfolder="unet", device_map="cuda"
                ... )
                >>> # This also works (integer accelerator device ID).
                >>> model = AutoModel.from_pretrained(
                ...     "stabilityai/stable-diffusion-xl-base-1.0", subfolder="unet", device_map=0
                ... )
                >>> # Specifying a supported offloading strategy like "auto" also works.
                >>> model = AutoModel.from_pretrained(
                ...     "stabilityai/stable-diffusion-xl-base-1.0", subfolder="unet", device_map="auto"
                ... )
                ```

                Set `device_map="auto"` to have 🤗 Accelerate automatically compute the most optimized `device_map`. For

Review comment (suggestion):
should be cased as `torch.device` for consistency with the dict value's type hint and the class name as written in torch

Code after:
            force_download (`bool`, *optional*, defaults to `False`):
                Whether or not to force the (re-)download of the model weights and configuration files, overriding the
                cached versions if they exist.
            proxies (`Dict[str, str]`, *optional*):
                A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128',
                'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request.
            output_loading_info (`bool`, *optional*, defaults to `False`):
                Whether or not to also return a dictionary containing missing keys, unexpected keys and error messages.
            local_files_only(`bool`, *optional*, defaults to `False`):
                Whether to only load local model weights and configuration files or not. If set to `True`, the model
                won't be downloaded from the Hub.
            token (`str` or *bool*, *optional*):
                The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from
                `diffusers-cli login` (stored in `~/.huggingface`) is used.
            revision (`str`, *optional*, defaults to `"main"`):
                The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier
                allowed by Git.
            from_flax (`bool`, *optional*, defaults to `False`):
                Load the model weights from a Flax checkpoint save file.
            subfolder (`str`, *optional*, defaults to `""`):
                The subfolder location of a model file within a larger model repository on the Hub or locally.
            mirror (`str`, *optional*):
                Mirror source to resolve accessibility issues if you're downloading a model in China. We do not
                guarantee the timeliness or safety of the source, and you should refer to the mirror site for more
                information.
            device_map (`Union[int, str, torch.device]` or `Dict[str, Union[int, str, torch.device]]`, *optional*):
                A map that specifies where each submodule should go. It doesn't need to be defined for each
                parameter/buffer name; once a given module name is inside, every submodule of it will be sent to the
                same device. Defaults to `None`, meaning that the model will be loaded on CPU.

                Examples:

                ```py
                >>> from diffusers import AutoModel
                >>> import torch

                >>> # This works.
                >>> model = AutoModel.from_pretrained(
                ...     "stabilityai/stable-diffusion-xl-base-1.0", subfolder="unet", device_map="cuda"
                ... )
                >>> # This also works (integer accelerator device ID).
                >>> model = AutoModel.from_pretrained(
                ...     "stabilityai/stable-diffusion-xl-base-1.0", subfolder="unet", device_map=0
                ... )
                >>> # Specifying a supported offloading strategy like "auto" also works.
                >>> model = AutoModel.from_pretrained(
                ...     "stabilityai/stable-diffusion-xl-base-1.0", subfolder="unet", device_map="auto"
                ... )
                >>> # Specifying a dictionary as `device_map` also works.
                >>> model = AutoModel.from_pretrained(
                ...     "stabilityai/stable-diffusion-xl-base-1.0",