
import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow


if is_torch_available():
					import torch

					from transformers import XLMRobertaModel







@require_sentencepiece
@require_tokenizers
@require_torch
class 				lowercase       ( unittest.TestCase    ):




				@slow
				def 					a							(      self ):
											snake_case_           =					XLMRobertaModel.from_pretrained('xlm-roberta-base' )
											snake_case_           =					torch.tensor([[0, 581, 1_0269, 83, 9_9942, 136, 6_0742, 23, 70, 8_0583, 1_8276, 2]] )
											# The dog is cute and lives in the garden house

											snake_case_           =					torch.Size((1, 12, 768) )  # batch_size, sequence_length, embedding_vector_dim
											snake_case_           =					torch.tensor(
											    [[-0.01_01, 0.12_18, -0.08_03, 0.08_01, 0.13_27, 0.07_76, -0.12_15, 0.23_83, 0.33_38, 0.31_06, 0.03_00, 0.02_52]] )
											#  xlmr = torch.hub.load('pytorch/fairseq', 'xlmr.base')
											#  xlmr.eval()
											#  expected_output_values_last_dim = xlmr.extract_features(input_ids[0])[:, :, -1]
											with torch.no_grad():
																		snake_case_           =					model(snake_case )['last_hidden_state'].detach()
											self.assertEqual(output.shape   ,     snake_case )
											# compare the actual values for a slice of last dim
											self.assertTrue(torch.allclose(output[:, :, -1]   ,     snake_case   ,     atol=1e-3 ) )




				@slow
				def 					a							(      self ):
											snake_case_           =					XLMRobertaModel.from_pretrained('xlm-roberta-large' )
											snake_case_           =					torch.tensor([[0, 581, 1_0269, 83, 9_9942, 136, 6_0742, 23, 70, 8_0583, 1_8276, 2]] )
											# The dog is cute and lives in the garden house

											snake_case_           =					torch.Size((1, 12, 1024) )  # batch_size, sequence_length, embedding_vector_dim
											snake_case_           =					torch.tensor(
											    [[-0.06_99, -0.03_18, 0.07_05, -0.12_41, 0.09_99, -0.05_20, 0.10_04, -0.18_38, -0.47_04, 0.14_37, 0.08_21, 0.01_26]] )
											#  xlmr = torch.hub.load('pytorch/fairseq', 'xlmr.large')
											#  xlmr.eval()
											#  expected_output_values_last_dim = xlmr.extract_features(input_ids[0])[:, :, -1]
											with torch.no_grad():
																		snake_case_           =					model(snake_case )['last_hidden_state'].detach()
											self.assertEqual(output.shape   ,     snake_case )
											# compare the actual values for a slice of last dim
											self.assertTrue(torch.allclose(output[:, :, -1]   ,     snake_case   ,     atol=1e-3 ) )







from dataclasses import dataclass
from typing import List, Optional, Union

import numpy as np
import PIL

from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available
from .timesteps import (
    fastaa_timesteps,
    smartaa_timesteps,
    smartaa_timesteps,
    smartaaa_timesteps,
    smartaaa_timesteps,
    superaa_timesteps,
    superaa_timesteps,
    superaaa_timesteps,
)







@dataclass
class 				lowercase       ( lowercase_    ):
				__SCREAMING_SNAKE_CASE      :				Union[List[PIL.Image.Image], np.ndarray]
				__SCREAMING_SNAKE_CASE      :				Optional[List[bool]]
				__SCREAMING_SNAKE_CASE      :				Optional[List[bool]]


try:
					if not (is_transformers_available() and is_torch_available()):
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					from ...utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
					from .pipeline_if import IFPipeline
					from .pipeline_if_imgaimg import IFImgaImgPipeline
					from .pipeline_if_imgaimg_superresolution import IFImgaImgSuperResolutionPipeline
					from .pipeline_if_inpainting import IFInpaintingPipeline
					from .pipeline_if_inpainting_superresolution import IFInpaintingSuperResolutionPipeline
					from .pipeline_if_superresolution import IFSuperResolutionPipeline
					from .safety_checker import IFSafetyChecker
					from .watermark import IFWatermarker




