code: 
  
  
  from typing import TYPE_CHECKING
  
  from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available
  
  
  UpperCamelCase__				       =			{
      'configuration_swin2sr': ['SWIN2SR_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Swin2SRConfig'],
  }
  
  
  try:
     if not is_torch_available():
        raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
     pass
  else:
     UpperCamelCase__				       =			[
         'SWIN2SR_PRETRAINED_MODEL_ARCHIVE_LIST',
         'Swin2SRForImageSuperResolution',
         'Swin2SRModel',
         'Swin2SRPreTrainedModel',
     ]
  
  
  try:
     if not is_vision_available():
        raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
     pass
  else:
     UpperCamelCase__				       =			['Swin2SRImageProcessor']
  
  
  if TYPE_CHECKING:
     from .configuration_swinasr import SWIN2SR_PRETRAINED_CONFIG_ARCHIVE_MAP, SwinaSRConfig
  
     try:
        if not is_torch_available():
           raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
        pass
     else:
        from .modeling_swinasr import (
            SWIN2SR_PRETRAINED_MODEL_ARCHIVE_LIST,
            SwinaSRForImageSuperResolution,
            SwinaSRModel,
            SwinaSRPreTrainedModel,
        )
  
     try:
        if not is_vision_available():
           raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
        pass
     else:
        from .image_processing_swinasr import SwinaSRImageProcessor
  
  
  else:
     import sys
  
     UpperCamelCase__				       =			_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)
style_context: 
  
  
  # limitations under the License.
  
  
  from typing import Optional, Tuple, Union
  
  import torch
  
  from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput
  
  class 						UpperCAmelCase__   (      A_		):
  
  
  
       '''simple docstring'''
  
  
  
  
       def __init__( self       :       List[str]	,      UpperCamelCase       :       Union[str, Any]	,      UpperCamelCase       :       int		):
  
  
  
  
  
              """simple docstring"""
  
  
  
              super().__init__()
              self.register_modules(unet=UpperCamelCase	,      scheduler=UpperCamelCase		)
  
  
  
  
       @torch.no_grad()
       def __call__( self       :       Any	,      UpperCamelCase       :       int = 1	,      UpperCamelCase       :       Optional[torch.Generator] = None	,      UpperCamelCase       :       int = 50	,      UpperCamelCase       :       Optional[str] = "pil"	,      UpperCamelCase       :       bool = True	,      **UpperCamelCase       :       int	,      ):
  
  
  
  
  
              """simple docstring"""
  
  
  
              _lowercase					:				Optional[int]           =			torch.randn(
                  (batch_size, self.unet.config.in_channels, self.unet.config.sample_size, self.unet.config.sample_size)	,      generator=UpperCamelCase	,      )
              _lowercase					:				Dict           =			image.to(self.device		)
  
              # set step values
              self.scheduler.set_timesteps(UpperCamelCase		)
  
              for t in self.progress_bar(self.scheduler.timesteps		):
                     # 1. predict noise model_output
                     _lowercase					:				Dict           =			self.unet(UpperCamelCase	,      UpperCamelCase		).sample
  
                     # 2. predict previous mean of image x_t-1 and add variance depending on eta
                     # eta corresponds to η in paper and should be between [0, 1]
                     # do x_t -> x_t-1
                     _lowercase					:				Tuple           =			self.scheduler.step(UpperCamelCase	,      UpperCamelCase	,      UpperCamelCase		).prev_sample
  
              _lowercase					:				Optional[int]           =			(image / 2 + 0.5).clamp(0	,      1		)
              _lowercase					:				int           =			image.cpu().permute(0	,      2	,      3	,      1		).numpy()
              if output_type == "pil":
                     _lowercase					:				List[Any]           =			self.numpy_to_pil(UpperCamelCase		)
  
              if not return_dict:
                     return (image,), "This is a local test"
  
              return ImagePipelineOutput(images=UpperCamelCase		), "This is a local test"