






import unittest

from transformers import (
    MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
    TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
    Pipeline,
    ZeroShotClassificationPipeline,
    pipeline,
)
from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow

from .test_pipelines_common import ANY


# These 2 model types require different inputs than those of the usual text models.
__snake_case      :      str             =       {"""LayoutLMv2Config""", """LayoutLMv3Config"""}


@is_pipeline_test
class       __SCREAMING_SNAKE_CASE   (				unittest.TestCase):
						_SCREAMING_SNAKE_CASE		:    Union[str, Any]						=   MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
						_SCREAMING_SNAKE_CASE		:    Dict						=   TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING

						if model_mapping is not None:
												_SCREAMING_SNAKE_CASE		:    str						=   {config: model for config, model in model_mapping.items() if config.__name__ not in _TO_SKIP}
						if tf_model_mapping is not None:
												_SCREAMING_SNAKE_CASE		:    Any						=   {
												    config: model for config, model in tf_model_mapping.items() if config.__name__ not in _TO_SKIP
												}






						def  UpperCamelCase__ (		self       ,  _UpperCamelCase       ,  _UpperCamelCase       ,  _UpperCamelCase				):






												"""simple docstring"""
												lowerCAmelCase__        =  ZeroShotClassificationPipeline(
												    model=_UpperCamelCase       ,  tokenizer=_UpperCamelCase       ,  candidate_labels=['polics', 'health']				)
												return classifier, ["Who are you voting for in 2020?", "My stomach hurts."]






						def  UpperCamelCase__ (		self       ,  _UpperCamelCase       ,  _UpperCamelCase				):






												"""simple docstring"""
												lowerCAmelCase__        =  classifier('Who are you voting for in 2020?'       ,  candidate_labels='politics'				)
												self.assertEqual(_UpperCamelCase       ,  {'sequence': ANY(_UpperCamelCase				), 'labels': [ANY(_UpperCamelCase				)], 'scores': [ANY(_UpperCamelCase				)]}				)

												# No kwarg
												lowerCAmelCase__        =  classifier('Who are you voting for in 2020?'       ,  ['politics']				)
												self.assertEqual(_UpperCamelCase       ,  {'sequence': ANY(_UpperCamelCase				), 'labels': [ANY(_UpperCamelCase				)], 'scores': [ANY(_UpperCamelCase				)]}				)

												lowerCAmelCase__        =  classifier('Who are you voting for in 2020?'       ,  candidate_labels=['politics']				)
												self.assertEqual(_UpperCamelCase       ,  {'sequence': ANY(_UpperCamelCase				), 'labels': [ANY(_UpperCamelCase				)], 'scores': [ANY(_UpperCamelCase				)]}				)

												lowerCAmelCase__        =  classifier('Who are you voting for in 2020?'       ,  candidate_labels='politics, public health'				)
												self.assertEqual(
												    _UpperCamelCase       ,  {'sequence': ANY(_UpperCamelCase				), 'labels': [ANY(_UpperCamelCase				), ANY(_UpperCamelCase				)], 'scores': [ANY(_UpperCamelCase				), ANY(_UpperCamelCase				)]}				)
												self.assertAlmostEqual(sum(nested_simplify(outputs['scores']				)				)       ,  1.0				)

												lowerCAmelCase__        =  classifier('Who are you voting for in 2020?'       ,  candidate_labels=['politics', 'public health']				)
												self.assertEqual(
												    _UpperCamelCase       ,  {'sequence': ANY(_UpperCamelCase				), 'labels': [ANY(_UpperCamelCase				), ANY(_UpperCamelCase				)], 'scores': [ANY(_UpperCamelCase				), ANY(_UpperCamelCase				)]}				)
												self.assertAlmostEqual(sum(nested_simplify(outputs['scores']				)				)       ,  1.0				)

												lowerCAmelCase__        =  classifier(
												    'Who are you voting for in 2020?'       ,  candidate_labels='politics'       ,  hypothesis_template='This text is about {}'				)
												self.assertEqual(_UpperCamelCase       ,  {'sequence': ANY(_UpperCamelCase				), 'labels': [ANY(_UpperCamelCase				)], 'scores': [ANY(_UpperCamelCase				)]}				)

												# https://github.com/huggingface/transformers/issues/13846
												lowerCAmelCase__        =  classifier(['I am happy']       ,  ['positive', 'negative']				)
												self.assertEqual(
												    _UpperCamelCase       ,  [
												        {'sequence': ANY(_UpperCamelCase				), 'labels': [ANY(_UpperCamelCase				), ANY(_UpperCamelCase				)], 'scores': [ANY(_UpperCamelCase				), ANY(_UpperCamelCase				)]}
												        for i in range(1				)
												    ]       ,  )
												lowerCAmelCase__        =  classifier(['I am happy', 'I am sad']       ,  ['positive', 'negative']				)
												self.assertEqual(
												    _UpperCamelCase       ,  [
												        {'sequence': ANY(_UpperCamelCase				), 'labels': [ANY(_UpperCamelCase				), ANY(_UpperCamelCase				)], 'scores': [ANY(_UpperCamelCase				), ANY(_UpperCamelCase				)]}
												        for i in range(2				)
												    ]       ,  )

												with self.assertRaises(_UpperCamelCase				):
																		classifier(''       ,  candidate_labels='politics'				)

												with self.assertRaises(_UpperCamelCase				):
																		classifier(_UpperCamelCase       ,  candidate_labels='politics'				)

												with self.assertRaises(_UpperCamelCase				):
																		classifier('Who are you voting for in 2020?'       ,  candidate_labels=''				)

												with self.assertRaises(_UpperCamelCase				):
																		classifier('Who are you voting for in 2020?'       ,  candidate_labels=_UpperCamelCase				)

												with self.assertRaises(_UpperCamelCase				):
																		classifier(
																		    'Who are you voting for in 2020?'       ,  candidate_labels='politics'       ,  hypothesis_template='Not formatting template'       ,  )

												with self.assertRaises(_UpperCamelCase				):
																		classifier(
																		    'Who are you voting for in 2020?'       ,  candidate_labels='politics'       ,  hypothesis_template=_UpperCamelCase       ,  )

												self.run_entailment_id(_UpperCamelCase				)






						def  UpperCamelCase__ (		self       ,  _UpperCamelCase				):






												"""simple docstring"""
												lowerCAmelCase__        =  zero_shot_classifier.model.config
												lowerCAmelCase__        =  config.labelaid
												lowerCAmelCase__        =  zero_shot_classifier.entailment_id

												lowerCAmelCase__        =  {'LABEL_0': 0, 'LABEL_1': 1, 'LABEL_2': 2}
												self.assertEqual(zero_shot_classifier.entailment_id       ,  -1				)

												lowerCAmelCase__        =  {'entailment': 0, 'neutral': 1, 'contradiction': 2}
												self.assertEqual(zero_shot_classifier.entailment_id       ,  0				)

												lowerCAmelCase__        =  {'ENTAIL': 0, 'NON-ENTAIL': 1}
												self.assertEqual(zero_shot_classifier.entailment_id       ,  0				)

												lowerCAmelCase__        =  {'ENTAIL': 2, 'NEUTRAL': 1, 'CONTR': 0}
												self.assertEqual(zero_shot_classifier.entailment_id       ,  2				)

												lowerCAmelCase__        =  original_labelaid
												self.assertEqual(_UpperCamelCase       ,  zero_shot_classifier.entailment_id				)






						@require_torch
						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												lowerCAmelCase__        =  pipeline(
												    'zero-shot-classification'       ,  model='sshleifer/tiny-distilbert-base-cased-distilled-squad'       ,  framework='pt'       ,  )
												# There was a regression in 4.10 for this
												# Adding a test so we don't make the mistake again.
												# https://github.com/huggingface/transformers/issues/13381#issuecomment-912343499
												zero_shot_classifier(
												    'Who are you voting for in 2020?' * 1_00       ,  candidate_labels=['politics', 'public health', 'science']				)






						@require_torch
						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												lowerCAmelCase__        =  pipeline(
												    'zero-shot-classification'       ,  model='sshleifer/tiny-distilbert-base-cased-distilled-squad'       ,  framework='pt'       ,  )
												lowerCAmelCase__        =  zero_shot_classifier(
												    'Who are you voting for in 2020?'       ,  candidate_labels=['politics', 'public health', 'science']				)

												self.assertEqual(
												    nested_simplify(_UpperCamelCase				)       ,  {
												        'sequence': 'Who are you voting for in 2020?',
												        'labels': ['science', 'public health', 'politics'],
												        'scores': [0.3_33, 0.3_33, 0.3_33],
												    }       ,  )






						@require_tf
						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												lowerCAmelCase__        =  pipeline(
												    'zero-shot-classification'       ,  model='sshleifer/tiny-distilbert-base-cased-distilled-squad'       ,  framework='tf'       ,  )
												lowerCAmelCase__        =  zero_shot_classifier(
												    'Who are you voting for in 2020?'       ,  candidate_labels=['politics', 'public health', 'science']				)

												self.assertEqual(
												    nested_simplify(_UpperCamelCase				)       ,  {
												        'sequence': 'Who are you voting for in 2020?',
												        'labels': ['science', 'public health', 'politics'],
												        'scores': [0.3_33, 0.3_33, 0.3_33],
												    }       ,  )






						@slow
						@require_torch
						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												lowerCAmelCase__        =  pipeline('zero-shot-classification'       ,  model='roberta-large-mnli'       ,  framework='pt'				)
												lowerCAmelCase__        =  zero_shot_classifier(
												    'Who are you voting for in 2020?'       ,  candidate_labels=['politics', 'public health', 'science']				)

												self.assertEqual(
												    nested_simplify(_UpperCamelCase				)       ,  {
												        'sequence': 'Who are you voting for in 2020?',
												        'labels': ['politics', 'public health', 'science'],
												        'scores': [0.9_76, 0.0_15, 0.0_09],
												    }       ,  )
												lowerCAmelCase__        =  zero_shot_classifier(
												    'The dominant sequence transduction models are based on complex recurrent or convolutional neural networks'
												    ' in an encoder-decoder configuration. The best performing models also connect the encoder and decoder'
												    ' through an attention mechanism. We propose a new simple network architecture, the Transformer, based'
												    ' solely on attention mechanisms, dispensing with recurrence and convolutions entirely. Experiments on two'
												    ' machine translation tasks show these models to be superior in quality while being more parallelizable'
												    ' and requiring significantly less time to train. Our model achieves 28.4 BLEU on the WMT 2014'
												    ' English-to-German translation task, improving over the existing best results, including ensembles by'
												    ' over 2 BLEU. On the WMT 2014 English-to-French translation task, our model establishes a new'
												    ' single-model state-of-the-art BLEU score of 41.8 after training for 3.5 days on eight GPUs, a small'
												    ' fraction of the training costs of the best models from the literature. We show that the Transformer'
												    ' generalizes well to other tasks by applying it successfully to English constituency parsing both with'
												    ' large and limited training data.'       ,  candidate_labels=['machine learning', 'statistics', 'translation', 'vision']       ,  multi_label=_UpperCamelCase       ,  )
												self.assertEqual(
												    nested_simplify(_UpperCamelCase				)       ,  {
												        'sequence': (
												            'The dominant sequence transduction models are based on complex recurrent or convolutional neural'
												            ' networks in an encoder-decoder configuration. The best performing models also connect the'
												            ' encoder and decoder through an attention mechanism. We propose a new simple network'
												            ' architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence'
												            ' and convolutions entirely. Experiments on two machine translation tasks show these models to be'
												            ' superior in quality while being more parallelizable and requiring significantly less time to'
												            ' train. Our model achieves 28.4 BLEU on the WMT 2014 English-to-German translation task,'
												            ' improving over the existing best results, including ensembles by over 2 BLEU. On the WMT 2014'
												            ' English-to-French translation task, our model establishes a new single-model state-of-the-art'
												            ' BLEU score of 41.8 after training for 3.5 days on eight GPUs, a small fraction of the training'
												            ' costs of the best models from the literature. We show that the Transformer generalizes well to'
												            ' other tasks by applying it successfully to English constituency parsing both with large and'
												            ' limited training data.'
												        ),
												        'labels': ['translation', 'machine learning', 'vision', 'statistics'],
												        'scores': [0.8_17, 0.7_13, 0.0_18, 0.0_18],
												    }       ,  )







						@slow
						@require_tf
						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												lowerCAmelCase__        =  pipeline('zero-shot-classification'       ,  model='roberta-large-mnli'       ,  framework='tf'				)
												lowerCAmelCase__        =  zero_shot_classifier(
												    'Who are you voting for in 2020?'       ,  candidate_labels=['politics', 'public health', 'science']				)

												self.assertEqual(
												    nested_simplify(_UpperCamelCase				)       ,  {
												        'sequence': 'Who are you voting for in 2020?',
												        'labels': ['politics', 'public health', 'science'],
												        'scores': [0.9_76, 0.0_15, 0.0_09],
												    }       ,  )
												lowerCAmelCase__        =  zero_shot_classifier(
												    'The dominant sequence transduction models are based on complex recurrent or convolutional neural networks'
												    ' in an encoder-decoder configuration. The best performing models also connect the encoder and decoder'
												    ' through an attention mechanism. We propose a new simple network architecture, the Transformer, based'
												    ' solely on attention mechanisms, dispensing with recurrence and convolutions entirely. Experiments on two'
												    ' machine translation tasks show these models to be superior in quality while being more parallelizable'
												    ' and requiring significantly less time to train. Our model achieves 28.4 BLEU on the WMT 2014'
												    ' English-to-German translation task, improving over the existing best results, including ensembles by'
												    ' over 2 BLEU. On the WMT 2014 English-to-French translation task, our model establishes a new'
												    ' single-model state-of-the-art BLEU score of 41.8 after training for 3.5 days on eight GPUs, a small'
												    ' fraction of the training costs of the best models from the literature. We show that the Transformer'
												    ' generalizes well to other tasks by applying it successfully to English constituency parsing both with'
												    ' large and limited training data.'       ,  candidate_labels=['machine learning', 'statistics', 'translation', 'vision']       ,  multi_label=_UpperCamelCase       ,  )
												self.assertEqual(
												    nested_simplify(_UpperCamelCase				)       ,  {
												        'sequence': (
												            'The dominant sequence transduction models are based on complex recurrent or convolutional neural'
												            ' networks in an encoder-decoder configuration. The best performing models also connect the'
												            ' encoder and decoder through an attention mechanism. We propose a new simple network'
												            ' architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence'
												            ' and convolutions entirely. Experiments on two machine translation tasks show these models to be'
												            ' superior in quality while being more parallelizable and requiring significantly less time to'
												            ' train. Our model achieves 28.4 BLEU on the WMT 2014 English-to-German translation task,'
												            ' improving over the existing best results, including ensembles by over 2 BLEU. On the WMT 2014'
												            ' English-to-French translation task, our model establishes a new single-model state-of-the-art'
												            ' BLEU score of 41.8 after training for 3.5 days on eight GPUs, a small fraction of the training'
												            ' costs of the best models from the literature. We show that the Transformer generalizes well to'
												            ' other tasks by applying it successfully to English constituency parsing both with large and'
												            ' limited training data.'
												        ),
												        'labels': ['translation', 'machine learning', 'vision', 'statistics'],
												        'scores': [0.8_17, 0.7_13, 0.0_18, 0.0_18],
												    }       ,  )













import unittest

import numpy as np
import torch
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    DPMSolverMultistepScheduler,
    TextToVideoSDPipeline,
    UNetaDConditionModel,
)
from diffusers.utils import is_xformers_available, load_numpy, skip_mps, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism

from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_PARAMS
from ..test_pipelines_common import PipelineTesterMixin


enable_full_determinism()


@skip_mps
class       __SCREAMING_SNAKE_CASE   (				__lowercase						,   unittest.TestCase):
						_SCREAMING_SNAKE_CASE		:    List[str]						=   TextToVideoSDPipeline
						_SCREAMING_SNAKE_CASE		:    str						=   TEXT_TO_IMAGE_PARAMS
						_SCREAMING_SNAKE_CASE		:    List[str]						=   TEXT_TO_IMAGE_BATCH_PARAMS
						# No `output_type`.
						_SCREAMING_SNAKE_CASE		:    Dict						=   frozenset(
						    [
						        '''num_inference_steps''',
						        '''generator''',
						        '''latents''',
						        '''return_dict''',
						        '''callback''',
						        '''callback_steps''',
						    ])






						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												torch.manual_seed(0				)
												lowerCAmelCase__        =  UNetaDConditionModel(
												    block_out_channels=(32, 64, 64, 64)       ,  layers_per_block=2       ,  sample_size=32       ,  in_channels=4       ,  out_channels=4       ,  down_block_types=('CrossAttnDownBlock3D', 'CrossAttnDownBlock3D', 'CrossAttnDownBlock3D', 'DownBlock3D')       ,  up_block_types=('UpBlock3D', 'CrossAttnUpBlock3D', 'CrossAttnUpBlock3D', 'CrossAttnUpBlock3D')       ,  cross_attention_dim=32       ,  attention_head_dim=4       ,  )
												lowerCAmelCase__        =  DDIMScheduler(
												    beta_start=0.0_00_85       ,  beta_end=0.0_12       ,  beta_schedule='scaled_linear'       ,  clip_sample=_UpperCamelCase       ,  set_alpha_to_one=_UpperCamelCase       ,  )
												torch.manual_seed(0				)
												lowerCAmelCase__        =  AutoencoderKL(
												    block_out_channels=[32, 64]       ,  in_channels=3       ,  out_channels=3       ,  down_block_types=['DownEncoderBlock2D', 'DownEncoderBlock2D']       ,  up_block_types=['UpDecoderBlock2D', 'UpDecoderBlock2D']       ,  latent_channels=4       ,  sample_size=1_28       ,  )
												torch.manual_seed(0				)
												lowerCAmelCase__        =  CLIPTextConfig(
												    bos_token_id=0       ,  eos_token_id=2       ,  hidden_size=32       ,  intermediate_size=37       ,  layer_norm_eps=1E-05       ,  num_attention_heads=4       ,  num_hidden_layers=5       ,  pad_token_id=1       ,  vocab_size=10_00       ,  hidden_act='gelu'       ,  projection_dim=5_12       ,  )
												lowerCAmelCase__        =  CLIPTextModel(_UpperCamelCase				)
												lowerCAmelCase__        =  CLIPTokenizer.from_pretrained('hf-internal-testing/tiny-random-clip'				)

												lowerCAmelCase__        =  {
												    'unet': unet,
												    'scheduler': scheduler,
												    'vae': vae,
												    'text_encoder': text_encoder,
												    'tokenizer': tokenizer,
												}
												return components






						def  UpperCamelCase__ (		self       ,  _UpperCamelCase       ,  _UpperCamelCase=0				):






												"""simple docstring"""
												if str(_UpperCamelCase				).startswith('mps'				):
																		lowerCAmelCase__        =  torch.manual_seed(_UpperCamelCase				)
												else:
																		lowerCAmelCase__        =  torch.Generator(device=_UpperCamelCase				).manual_seed(_UpperCamelCase				)
												lowerCAmelCase__        =  {
												    'prompt': 'A painting of a squirrel eating a burger',
												    'generator': generator,
												    'num_inference_steps': 2,
												    'guidance_scale': 6.0,
												    'output_type': 'pt',
												}
												return inputs






						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												lowerCAmelCase__        =  'cpu'  # ensure determinism for the device-dependent torch.Generator
												lowerCAmelCase__        =  self.get_dummy_components()
												lowerCAmelCase__        =  TextToVideoSDPipeline(**_UpperCamelCase				)
												lowerCAmelCase__        =  sd_pipe.to(_UpperCamelCase				)
												sd_pipe.set_progress_bar_config(disable=_UpperCamelCase				)

												lowerCAmelCase__        =  self.get_dummy_inputs(_UpperCamelCase				)
												lowerCAmelCase__        =  'np'
												lowerCAmelCase__        =  sd_pipe(**_UpperCamelCase				).frames
												lowerCAmelCase__        =  frames[0][-3:, -3:, -1]

												assert frames[0].shape == (64, 64, 3)
												lowerCAmelCase__        =  np.array([1_58.0, 1_60.0, 1_53.0, 1_25.0, 1_00.0, 1_21.0, 1_11.0, 93.0, 1_13.0]				)

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






						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												self._test_attention_slicing_forward_pass(test_mean_pixel_difference=_UpperCamelCase       ,  expected_max_diff=3E-3				)






						@unittest.skipIf(
						    torch_device != 'cuda' or not is_xformers_available()       ,  reason='XFormers attention is only available with CUDA and `xformers` installed'       ,  )
						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												self._test_xformers_attention_forwardGenerator_pass(test_mean_pixel_difference=_UpperCamelCase       ,  expected_max_diff=1E-2				)






						@unittest.skip(reason='Batching needs to be properly figured out first for this pipeline.'				)
						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												pass






						@unittest.skip(reason='Batching needs to be properly figured out first for this pipeline.'				)
						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												pass






						@unittest.skip(reason='`num_images_per_prompt` argument is not supported for this pipeline.'				)
						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												pass







						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												return super().test_progress_bar()




@slow
@skip_mps
class       __SCREAMING_SNAKE_CASE   (				unittest.TestCase):






						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												lowerCAmelCase__        =  load_numpy(
												    'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/text_to_video/video.npy'				)

												lowerCAmelCase__        =  TextToVideoSDPipeline.from_pretrained('damo-vilab/text-to-video-ms-1.7b'				)
												lowerCAmelCase__        =  DPMSolverMultistepScheduler.from_config(pipe.scheduler.config				)
												lowerCAmelCase__        =  pipe.to('cuda'				)

												lowerCAmelCase__        =  'Spiderman is surfing'
												lowerCAmelCase__        =  torch.Generator(device='cpu'				).manual_seed(0				)

												lowerCAmelCase__        =  pipe(_UpperCamelCase       ,  generator=_UpperCamelCase       ,  num_inference_steps=25       ,  output_type='pt'				).frames
												lowerCAmelCase__        =  video_frames.cpu().numpy()

												assert np.abs(expected_video - video				).mean() < 5E-2







						def  UpperCamelCase__ (		self				):






												"""simple docstring"""
												lowerCAmelCase__        =  load_numpy(
												    'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/text_to_video/video_2step.npy'				)

												lowerCAmelCase__        =  TextToVideoSDPipeline.from_pretrained('damo-vilab/text-to-video-ms-1.7b'				)
												lowerCAmelCase__        =  pipe.to('cuda'				)

												lowerCAmelCase__        =  'Spiderman is surfing'
												lowerCAmelCase__        =  torch.Generator(device='cpu'				).manual_seed(0				)

												lowerCAmelCase__        =  pipe(_UpperCamelCase       ,  generator=_UpperCamelCase       ,  num_inference_steps=2       ,  output_type='pt'				).frames
												lowerCAmelCase__        =  video_frames.cpu().numpy()

												assert np.abs(expected_video - video				).mean() < 5E-2





