





import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionImageVariationPipeline
from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device


_UpperCAmelCase       : Union[str, Any]			     =       False

class      lowerCAmelCase							(      unittest.TestCase    ):
 pass


@slow
@require_torch_gpu
class      lowerCAmelCase							(      unittest.TestCase    ):
 def   A_			(   self						:   Tuple			)    ->			Optional[int]:
     lowerCamelCase__					:   Union[str, Any]      				=	VersatileDiffusionImageVariationPipeline.from_pretrained('shi-labs/versatile-diffusion'			)
     pipe.to(UpperCAmelCase			)
     pipe.set_progress_bar_config(disable=UpperCAmelCase			)

     lowerCamelCase__					:   int      				=	load_image(
         'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg'			)
     lowerCamelCase__					:   int      				=	torch.manual_seed(0			)
     lowerCamelCase__					:   str      				=	pipe(
         image=UpperCAmelCase    ,  generator=UpperCAmelCase    ,  guidance_scale=7.5    ,  num_inference_steps=50    ,  output_type='numpy'    ,  ).images

     lowerCamelCase__					:   Tuple      				=	image[0, 253:256, 253:256, -1]

     assert image.shape == (1, 512, 512, 3)
     lowerCamelCase__					:   List[Any]      				=	np.array([0.0_4_4_1, 0.0_4_6_9, 0.0_5_0_7, 0.0_5_7_5, 0.0_6_3_2, 0.0_6_5_0, 0.0_8_6_5, 0.0_9_0_9, 0.0_9_4_5]			)

     assert np.abs(image_slice.flatten() - expected_slice			).max() < 1e-2












from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_UpperCAmelCase       : List[str]			     =       {
    """configuration_autoformer""": [
        """AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """AutoformerConfig""",
    ],
}

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _UpperCAmelCase       : List[Any]			     =       [
        """AUTOFORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
        """AutoformerForPrediction""",
        """AutoformerModel""",
        """AutoformerPreTrainedModel""",
    ]


if TYPE_CHECKING:
    from .configuration_autoformer import (
        AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
        AutoformerConfig,
    )

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_autoformer import (
            AUTOFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
            AutoformerForPrediction,
            AutoformerModel,
            AutoformerPreTrainedModel,
        )

else:
    import sys

    _UpperCAmelCase       : Dict			     =       _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





