


"""simple docstring"""






import unittest

from huggingface_hub import hf_hub_download

from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor
from transformers.pipelines import VideoClassificationPipeline, pipeline
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_decord,
    require_tf,
    require_torch,
    require_torch_or_tf,
    require_vision,
)

from .test_pipelines_common import ANY


@is_pipeline_test
@require_torch_or_tf
@require_vision
@require_decord
class     __lowerCamelCase  (					unittest.TestCase				):

     '''simple docstring'''
     A_       :	str    =		MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING


     def 							_UpperCAmelCase      (      self    ,				__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase							)       ->							Union[str, Any]:
          _a    	=				hf_hub_download(
              repo_id='''nateraw/video-demo'''    ,				filename='''archery.mp4'''    ,				repo_type='''dataset'''							)
          _a    	=				VideoClassificationPipeline(model=__UpperCAmelCase    ,				image_processor=__UpperCAmelCase    ,				top_k=2							)
          _a    	=				[
              example_video_filepath,
              '''https://huggingface.co/datasets/nateraw/video-demo/resolve/main/archery.mp4''',
          ]
          return video_classifier, examples


     def 							_UpperCAmelCase      (      self    ,				__UpperCAmelCase    ,				__UpperCAmelCase							)       ->							Union[str, Any]:
          for example in examples:
               _a    	=				video_classifier(__UpperCAmelCase							)

               self.assertEqual(
                   __UpperCAmelCase    ,				[
                       {'''score''': ANY(__UpperCAmelCase							), '''label''': ANY(__UpperCAmelCase							)},
                       {'''score''': ANY(__UpperCAmelCase							), '''label''': ANY(__UpperCAmelCase							)},
                   ]    ,				)


     @require_torch
     def 							_UpperCAmelCase      (      self							)       ->							Any:
          _a    	=				'''hf-internal-testing/tiny-random-VideoMAEForVideoClassification'''
          _a    	=				VideoMAEFeatureExtractor(
              size={'''shortest_edge''': 10}    ,				crop_size={'''height''': 10, '''width''': 10}							)
          _a    	=				pipeline(
              '''video-classification'''    ,				model=__UpperCAmelCase    ,				feature_extractor=__UpperCAmelCase    ,				frame_sampling_rate=4							)

          _a    	=				hf_hub_download(repo_id='''nateraw/video-demo'''    ,				filename='''archery.mp4'''    ,				repo_type='''dataset'''							)
          _a    	=				video_classifier(__UpperCAmelCase    ,				top_k=2							)
          self.assertEqual(
              nested_simplify(__UpperCAmelCase    ,				decimals=4							)    ,				[{'''score''': 0.5199, '''label''': '''LABEL_0'''}, {'''score''': 0.4801, '''label''': '''LABEL_1'''}]    ,				)

          _a    	=				video_classifier(
              [
                  video_file_path,
                  video_file_path,
              ]    ,				top_k=2    ,				)
          self.assertEqual(
              nested_simplify(__UpperCAmelCase    ,				decimals=4							)    ,				[
                  [{'''score''': 0.5199, '''label''': '''LABEL_0'''}, {'''score''': 0.4801, '''label''': '''LABEL_1'''}],
                  [{'''score''': 0.5199, '''label''': '''LABEL_0'''}, {'''score''': 0.4801, '''label''': '''LABEL_1'''}],
              ]    ,				)





     @require_tf
     def 							_UpperCAmelCase      (      self							)       ->							Tuple:
          pass



"""simple docstring"""






def       A_   (   _lowerCAmelCase     :					list,     _lowerCAmelCase     :					list,     _lowerCAmelCase     :					int       ):






     """simple docstring"""

     _a    	=				len(_lowerCAmelCase       )
     _a    	=				[[0] * n for i in range(_lowerCAmelCase       )]
     for i in range(_lowerCAmelCase       ):
          _a    	=				y_points[i]

     for i in range(2,     _lowerCAmelCase       ):
          for j in range(_lowerCAmelCase,     _lowerCAmelCase       ):
               _a    	=				(
                   (xa - x_points[j - i + 1]) * q[j][i - 1]
                   - (xa - x_points[j]) * q[j - 1][i - 1]
               ) / (x_points[j] - x_points[j - i + 1])

     return [q[n - 1][n - 1], q]


if __name__ == "__main__":
   import doctest

   doctest.testmod()