



"""simple docstring"""
import copy
import inspect
import unittest

import numpy as np
from huggingface_hub import hf_hub_download

from transformers import VideoMAEConfig
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
      import torch
      from torch import nn

      from transformers import (
          MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING,
          VideoMAEForPreTraining,
          VideoMAEForVideoClassification,
          VideoMAEModel,
      )
      from transformers.models.videomae.modeling_videomae import VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
      from transformers import VideoMAEImageProcessor



class       SCREAMING_SNAKE_CASE__  :

   def __init__(   self      ,     _SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE=13      ,     _SCREAMING_SNAKE_CASE=10      ,     _SCREAMING_SNAKE_CASE=3      ,     _SCREAMING_SNAKE_CASE=2      ,     _SCREAMING_SNAKE_CASE=2      ,     _SCREAMING_SNAKE_CASE=2      ,     _SCREAMING_SNAKE_CASE=True      ,     _SCREAMING_SNAKE_CASE=True      ,     _SCREAMING_SNAKE_CASE=32      ,     _SCREAMING_SNAKE_CASE=5      ,     _SCREAMING_SNAKE_CASE=4      ,     _SCREAMING_SNAKE_CASE=37      ,     _SCREAMING_SNAKE_CASE="gelu"      ,     _SCREAMING_SNAKE_CASE=0.1      ,     _SCREAMING_SNAKE_CASE=0.1      ,     _SCREAMING_SNAKE_CASE=10      ,     _SCREAMING_SNAKE_CASE=0.02      ,     _SCREAMING_SNAKE_CASE=0.9      ,     _SCREAMING_SNAKE_CASE=None      ,     )  ->      Any:





    '''simple docstring'''




    UpperCAmelCase	:					int	=	parent
    UpperCAmelCase	:					Union[str, Any]	=	batch_size
    UpperCAmelCase	:					List[str]	=	image_size
    UpperCAmelCase	:					Any	=	num_channels
    UpperCAmelCase	:					Any	=	patch_size
    UpperCAmelCase	:					Optional[Any]	=	tubelet_size
    UpperCAmelCase	:					List[Any]	=	num_frames
    UpperCAmelCase	:					List[Any]	=	is_training
    UpperCAmelCase	:					Any	=	use_labels
    UpperCAmelCase	:					Tuple	=	hidden_size
    UpperCAmelCase	:					Tuple	=	num_hidden_layers
    UpperCAmelCase	:					Optional[int]	=	num_attention_heads
    UpperCAmelCase	:					Optional[Any]	=	intermediate_size
    UpperCAmelCase	:					Optional[int]	=	hidden_act
    UpperCAmelCase	:					Optional[int]	=	hidden_dropout_prob
    UpperCAmelCase	:					Optional[Any]	=	attention_probs_dropout_prob
    UpperCAmelCase	:					Optional[Any]	=	type_sequence_label_size
    UpperCAmelCase	:					Optional[int]	=	initializer_range
    UpperCAmelCase	:					int	=	mask_ratio
    UpperCAmelCase	:					List[Any]	=	scope

    # in VideoMAE, the number of tokens equals num_frames/tubelet_size * num_patches per frame
    UpperCAmelCase	:					Tuple	=	(image_size // patch_size) ** 2
    UpperCAmelCase	:					Tuple	=	(num_frames // tubelet_size) * self.num_patches_per_frame

    # use this variable to define bool_masked_pos
    UpperCAmelCase	:					str	=	int(mask_ratio * self.seq_length						)

   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      List[str]:





    '''simple docstring'''




    UpperCAmelCase	:					Tuple	=	floats_tensor(
        [self.batch_size, self.num_frames, self.num_channels, self.image_size, self.image_size]						)

    UpperCAmelCase	:					int	=	None
    if self.use_labels:
     UpperCAmelCase	:					Optional[int]	=	ids_tensor([self.batch_size]      ,     self.type_sequence_label_size						)

    UpperCAmelCase	:					Optional[Any]	=	self.get_config()

    return config, pixel_values, labels

   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      List[str]:





    '''simple docstring'''




    return VideoMAEConfig(
        image_size=self.image_size      ,     patch_size=self.patch_size      ,     num_channels=self.num_channels      ,     num_frames=self.num_frames      ,     tubelet_size=self.tubelet_size      ,     hidden_size=self.hidden_size      ,     num_hidden_layers=self.num_hidden_layers      ,     num_attention_heads=self.num_attention_heads      ,     intermediate_size=self.intermediate_size      ,     hidden_act=self.hidden_act      ,     hidden_dropout_prob=self.hidden_dropout_prob      ,     attention_probs_dropout_prob=self.attention_probs_dropout_prob      ,     is_decoder=_SCREAMING_SNAKE_CASE      ,     initializer_range=self.initializer_range      ,     )

   def 	SCREAMING_SNAKE_CASE     (   self      ,     _SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE						)  ->      Optional[int]:





    '''simple docstring'''




    UpperCAmelCase	:					str	=	VideoMAEModel(config=_SCREAMING_SNAKE_CASE						)
    model.to(_SCREAMING_SNAKE_CASE						)
    model.eval()
    UpperCAmelCase	:					Optional[int]	=	model(_SCREAMING_SNAKE_CASE						)
    self.parent.assertEqual(result.last_hidden_state.shape      ,     (self.batch_size, self.seq_length, self.hidden_size)						)

   def 	SCREAMING_SNAKE_CASE     (   self      ,     _SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE						)  ->      Dict:





    '''simple docstring'''




    UpperCAmelCase	:					int	=	VideoMAEForPreTraining(_SCREAMING_SNAKE_CASE						)
    model.to(_SCREAMING_SNAKE_CASE						)
    model.eval()
    # important: each video needs to have the same number of masked patches
    # hence we define a single mask, which we then repeat for each example in the batch
    UpperCAmelCase	:					Optional[Any]	=	torch.ones((self.num_masks,)						)
    UpperCAmelCase	:					Optional[int]	=	torch.cat([mask, torch.zeros(self.seq_length - mask.size(0						)						)]						)
    UpperCAmelCase	:					Tuple	=	mask.expand(self.batch_size      ,     -1						).bool()

    UpperCAmelCase	:					Optional[Any]	=	model(_SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE						)
    # model only returns predictions for masked patches
    UpperCAmelCase	:					int	=	mask.sum().item()
    UpperCAmelCase	:					Tuple	=	3 * self.tubelet_size * self.patch_size**2
    self.parent.assertEqual(result.logits.shape      ,     (self.batch_size, num_masked_patches, decoder_num_labels)						)




   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      List[Any]:





    '''simple docstring'''




    UpperCAmelCase	:					Tuple	=	self.prepare_config_and_inputs()
    UpperCAmelCase	,		UpperCAmelCase	,		UpperCAmelCase	:					List[str]	=	config_and_inputs
    UpperCAmelCase	:					Tuple	=	{"""pixel_values""": pixel_values}
    return config, inputs_dict



@require_torch
class       SCREAMING_SNAKE_CASE__  (					UpperCAmelCase__      ,			UpperCAmelCase__      ,			unittest.TestCase ):
   __lowerCAmelCase  :   Union[str, Any]						=						(
       (VideoMAEModel, VideoMAEForPreTraining, VideoMAEForVideoClassification) if is_torch_available() else ()
   )
   __lowerCAmelCase  :   Tuple						=						(
       {'feature-extraction': VideoMAEModel, 'video-classification': VideoMAEForVideoClassification}
       if is_torch_available()
       else {}
   )

   __lowerCAmelCase  :   str						=						False
   __lowerCAmelCase  :   Optional[Any]						=						False
   __lowerCAmelCase  :   Optional[int]						=						False
   __lowerCAmelCase  :   str						=						False

   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      Tuple:





    '''simple docstring'''




    UpperCAmelCase	:					Optional[Any]	=	VideoMAEModelTester(self						)
    UpperCAmelCase	:					Union[str, Any]	=	ConfigTester(self      ,     config_class=_SCREAMING_SNAKE_CASE      ,     has_text_modality=_SCREAMING_SNAKE_CASE      ,     hidden_size=37						)

   def 	SCREAMING_SNAKE_CASE     (   self      ,     _SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE=False						)  ->      int:





    '''simple docstring'''




    UpperCAmelCase	:					Tuple	=	copy.deepcopy(_SCREAMING_SNAKE_CASE						)

    if model_class == VideoMAEForPreTraining:
     # important: each video needs to have the same number of masked patches
     # hence we define a single mask, which we then repeat for each example in the batch
     UpperCAmelCase	:					Union[str, Any]	=	torch.ones((self.model_tester.num_masks,)						)
     UpperCAmelCase	:					str	=	torch.cat([mask, torch.zeros(self.model_tester.seq_length - mask.size(0						)						)]						)
     UpperCAmelCase	:					List[str]	=	mask.expand(self.model_tester.batch_size      ,     -1						).bool()
     UpperCAmelCase	:					str	=	bool_masked_pos.to(_SCREAMING_SNAKE_CASE						)

    if return_labels:
     if model_class in [
         *get_values(_SCREAMING_SNAKE_CASE						),
     ]:
      UpperCAmelCase	:					Optional[Any]	=	torch.zeros(
          self.model_tester.batch_size      ,     dtype=torch.long      ,     device=_SCREAMING_SNAKE_CASE						)

    return inputs_dict

   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      str:





    '''simple docstring'''




    self.config_tester.run_common_tests()

   @unittest.skip(reason="""VideoMAE does not use inputs_embeds"""						)
   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      List[Any]:





    '''simple docstring'''




    pass

   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      Optional[int]:





    '''simple docstring'''




    UpperCAmelCase	,		UpperCAmelCase	:					int	=	self.model_tester.prepare_config_and_inputs_for_common()

    for model_class in self.all_model_classes:
     UpperCAmelCase	:					Dict	=	model_class(_SCREAMING_SNAKE_CASE						)
     self.assertIsInstance(model.get_input_embeddings()      ,     (nn.Module)						)
     UpperCAmelCase	:					int	=	model.get_output_embeddings()
     self.assertTrue(x is None or isinstance(_SCREAMING_SNAKE_CASE      ,     nn.Linear						)						)

   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      Optional[Any]:





    '''simple docstring'''




    UpperCAmelCase	,		UpperCAmelCase	:					int	=	self.model_tester.prepare_config_and_inputs_for_common()

    for model_class in self.all_model_classes:
     UpperCAmelCase	:					Any	=	model_class(_SCREAMING_SNAKE_CASE						)
     UpperCAmelCase	:					Optional[int]	=	inspect.signature(model.forward						)
     # signature.parameters is an OrderedDict => so arg_names order is deterministic
     UpperCAmelCase	:					List[Any]	=	[*signature.parameters.keys()]

     UpperCAmelCase	:					List[Any]	=	["""pixel_values"""]
     self.assertListEqual(arg_names[:1]      ,     _SCREAMING_SNAKE_CASE						)

   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      str:





    '''simple docstring'''




    UpperCAmelCase	:					Any	=	self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_model(*_SCREAMING_SNAKE_CASE						)

   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      List[Any]:





    '''simple docstring'''




    UpperCAmelCase	:					Tuple	=	self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_pretraining(*_SCREAMING_SNAKE_CASE						)

   @slow
   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      Tuple:





    '''simple docstring'''




    for model_name in VIDEOMAE_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
     UpperCAmelCase	:					Tuple	=	VideoMAEModel.from_pretrained(_SCREAMING_SNAKE_CASE						)
     self.assertIsNotNone(_SCREAMING_SNAKE_CASE						)

   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      str:





    '''simple docstring'''




    if not self.has_attentions:
     pass

    else:
     UpperCAmelCase	,		UpperCAmelCase	:					int	=	self.model_tester.prepare_config_and_inputs_for_common()
     UpperCAmelCase	:					Any	=	True

     for model_class in self.all_model_classes:
      UpperCAmelCase	:					Optional[int]	=	self.model_tester.seq_length - self.model_tester.num_masks
      UpperCAmelCase	:					Dict	=	(
          num_visible_patches if model_class == VideoMAEForPreTraining else self.model_tester.seq_length
      )

      UpperCAmelCase	:					str	=	True
      UpperCAmelCase	:					int	=	False
      UpperCAmelCase	:					List[str]	=	True
      UpperCAmelCase	:					List[str]	=	model_class(_SCREAMING_SNAKE_CASE						)
      model.to(_SCREAMING_SNAKE_CASE						)
      model.eval()
      with torch.no_grad():
       UpperCAmelCase	:					List[Any]	=	model(**self._prepare_for_class(_SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE						)						)
      UpperCAmelCase	:					Tuple	=	outputs.attentions
      self.assertEqual(len(_SCREAMING_SNAKE_CASE						)      ,     self.model_tester.num_hidden_layers						)

      # check that output_attentions also work using config
      del inputs_dict["output_attentions"]
      UpperCAmelCase	:					Union[str, Any]	=	True
      UpperCAmelCase	:					List[Any]	=	model_class(_SCREAMING_SNAKE_CASE						)
      model.to(_SCREAMING_SNAKE_CASE						)
      model.eval()
      with torch.no_grad():
       UpperCAmelCase	:					Union[str, Any]	=	model(**self._prepare_for_class(_SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE						)						)
      UpperCAmelCase	:					str	=	outputs.attentions
      self.assertEqual(len(_SCREAMING_SNAKE_CASE						)      ,     self.model_tester.num_hidden_layers						)

      self.assertListEqual(
          list(attentions[0].shape[-3:]						)      ,     [self.model_tester.num_attention_heads, seq_len, seq_len]      ,     )
      UpperCAmelCase	:					List[Any]	=	len(_SCREAMING_SNAKE_CASE						)

      # Check attention is always last and order is fine
      UpperCAmelCase	:					Optional[int]	=	True
      UpperCAmelCase	:					str	=	True
      UpperCAmelCase	:					List[str]	=	model_class(_SCREAMING_SNAKE_CASE						)
      model.to(_SCREAMING_SNAKE_CASE						)
      model.eval()
      with torch.no_grad():
       UpperCAmelCase	:					int	=	model(**self._prepare_for_class(_SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE						)						)

      self.assertEqual(out_len + 1      ,     len(_SCREAMING_SNAKE_CASE						)						)

      UpperCAmelCase	:					List[Any]	=	outputs.attentions

      self.assertEqual(len(_SCREAMING_SNAKE_CASE						)      ,     self.model_tester.num_hidden_layers						)
      self.assertListEqual(
          list(self_attentions[0].shape[-3:]						)      ,     [self.model_tester.num_attention_heads, seq_len, seq_len]      ,     )

   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      Union[str, Any]:





    '''simple docstring'''




    def check_hidden_states_output(_SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE						):
     UpperCAmelCase	:					Any	=	model_class(_SCREAMING_SNAKE_CASE						)
     model.to(_SCREAMING_SNAKE_CASE						)
     model.eval()

     with torch.no_grad():
      UpperCAmelCase	:					Tuple	=	model(**self._prepare_for_class(_SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE						)						)

     UpperCAmelCase	:					int	=	outputs.hidden_states
     UpperCAmelCase	:					Tuple	=	self.model_tester.num_hidden_layers + 1
     self.assertEqual(len(_SCREAMING_SNAKE_CASE						)      ,     _SCREAMING_SNAKE_CASE						)

     UpperCAmelCase	:					Tuple	=	self.model_tester.seq_length - self.model_tester.num_masks
     UpperCAmelCase	:					Optional[int]	=	num_visible_patches if model_class == VideoMAEForPreTraining else self.model_tester.seq_length

     self.assertListEqual(
         list(hidden_states[0].shape[-2:]						)      ,     [seq_length, self.model_tester.hidden_size]      ,     )

    UpperCAmelCase	,		UpperCAmelCase	:					int	=	self.model_tester.prepare_config_and_inputs_for_common()

    for model_class in self.all_model_classes:
     UpperCAmelCase	:					Tuple	=	True
     check_hidden_states_output(_SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE						)

     # check that output_hidden_states also work using config
     del inputs_dict["output_hidden_states"]
     UpperCAmelCase	:					Dict	=	True

     check_hidden_states_output(_SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE      ,     _SCREAMING_SNAKE_CASE						)




   @unittest.skip("""Will be fixed soon by reducing the size of the model used for common tests."""						)
   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      str:





    '''simple docstring'''




    pass

def       _snake_case						(						):
 UpperCAmelCase	:					List[Any]	=	hf_hub_download(
     repo_id="""hf-internal-testing/spaghetti-video"""			,		filename="""eating_spaghetti.npy"""			,		repo_type="""dataset"""						)
 UpperCAmelCase	:					Optional[Any]	=	np.load(UpperCamelCase						)
 return list(UpperCamelCase						)



@require_torch
@require_vision
class       SCREAMING_SNAKE_CASE__  (					unittest.TestCase ):

   @cached_property
   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      Dict:





    '''simple docstring'''




    return (
        VideoMAEImageProcessor(image_mean=[0.5, 0.5, 0.5]      ,     image_std=[0.5, 0.5, 0.5]						)
        if is_vision_available()
        else None
    )

   @slow
   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      Any:





    '''simple docstring'''




    UpperCAmelCase	:					Union[str, Any]	=	VideoMAEForVideoClassification.from_pretrained("""MCG-NJU/videomae-base-finetuned-kinetics"""						).to(
        _SCREAMING_SNAKE_CASE						)

    UpperCAmelCase	:					Any	=	self.default_image_processor
    UpperCAmelCase	:					Optional[int]	=	prepare_video()
    UpperCAmelCase	:					int	=	image_processor(_SCREAMING_SNAKE_CASE      ,     return_tensors="""pt"""						).to(_SCREAMING_SNAKE_CASE						)

    # forward pass
    with torch.no_grad():
     UpperCAmelCase	:					List[Any]	=	model(**_SCREAMING_SNAKE_CASE						)

    # verify the logits
    UpperCAmelCase	:					str	=	torch.Size((1, 400)						)
    self.assertEqual(outputs.logits.shape      ,     _SCREAMING_SNAKE_CASE						)

    UpperCAmelCase	:					int	=	torch.tensor([0.3669, -0.0688, -0.2421]						).to(_SCREAMING_SNAKE_CASE						)

    self.assertTrue(torch.allclose(outputs.logits[0, :3]      ,     _SCREAMING_SNAKE_CASE      ,     atol=1E-4						)						)




   @slow
   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      List[Any]:





    '''simple docstring'''




    UpperCAmelCase	:					Tuple	=	VideoMAEForPreTraining.from_pretrained("""MCG-NJU/videomae-base-short"""						).to(_SCREAMING_SNAKE_CASE						)

    UpperCAmelCase	:					str	=	self.default_image_processor
    UpperCAmelCase	:					Dict	=	prepare_video()
    UpperCAmelCase	:					List[Any]	=	image_processor(_SCREAMING_SNAKE_CASE      ,     return_tensors="""pt"""						).to(_SCREAMING_SNAKE_CASE						)

    # add boolean mask, indicating which patches to mask
    UpperCAmelCase	:					Tuple	=	hf_hub_download(repo_id="""hf-internal-testing/bool-masked-pos"""      ,     filename="""bool_masked_pos.pt"""						)
    UpperCAmelCase	:					Any	=	torch.load(_SCREAMING_SNAKE_CASE						)

    # forward pass
    with torch.no_grad():
     UpperCAmelCase	:					Optional[int]	=	model(**_SCREAMING_SNAKE_CASE						)

    # verify the logits
    UpperCAmelCase	:					Optional[int]	=	torch.Size([1, 1408, 1536]						)
    UpperCAmelCase	:					str	=	torch.tensor(
        [[0.7994, 0.9612, 0.8508], [0.7401, 0.8958, 0.8302], [0.5862, 0.7468, 0.7325]]      ,     device=_SCREAMING_SNAKE_CASE						)
    self.assertEqual(outputs.logits.shape      ,     _SCREAMING_SNAKE_CASE						)
    self.assertTrue(torch.allclose(outputs.logits[0, :3, :3]      ,     _SCREAMING_SNAKE_CASE      ,     atol=1E-4						)						)

    # verify the loss (`config.norm_pix_loss` = `True`)
    UpperCAmelCase	:					Any	=	torch.tensor([0.5142]      ,     device=_SCREAMING_SNAKE_CASE						)
    self.assertTrue(torch.allclose(outputs.loss      ,     _SCREAMING_SNAKE_CASE      ,     atol=1E-4						)						)

    # verify the loss (`config.norm_pix_loss` = `False`)
    UpperCAmelCase	:					Optional[int]	=	VideoMAEForPreTraining.from_pretrained("""MCG-NJU/videomae-base-short"""      ,     norm_pix_loss=_SCREAMING_SNAKE_CASE						).to(
        _SCREAMING_SNAKE_CASE						)

    with torch.no_grad():
     UpperCAmelCase	:					Optional[int]	=	model(**_SCREAMING_SNAKE_CASE						)

    UpperCAmelCase	:					Optional[Any]	=	torch.tensor(torch.tensor([0.6469]						)      ,     device=_SCREAMING_SNAKE_CASE						)
    self.assertTrue(torch.allclose(outputs.loss      ,     _SCREAMING_SNAKE_CASE      ,     atol=1E-4						)						)





"""simple docstring"""
def       _snake_case						(						UpperCamelCase						:		list						):
 if not isinstance(UpperCamelCase			,		UpperCamelCase						):
  raise ValueError("""Input series is not valid, valid series - [2, 4, 6]"""						)
 if len(UpperCamelCase						) == 0:
  raise ValueError("""Input list must be a non empty list"""						)
 if len(UpperCamelCase						) == 1:
  return True
 UpperCAmelCase	:					Union[str, Any]	=	series[1] - series[0]
 for index in range(len(UpperCamelCase						) - 1						):
  if series[index + 1] - series[index] != common_diff:
   return False
 return True

def       _snake_case						(						UpperCamelCase						:		list						):
 if not isinstance(UpperCamelCase			,		UpperCamelCase						):
  raise ValueError("""Input series is not valid, valid series - [2, 4, 6]"""						)
 if len(UpperCamelCase						) == 0:
  raise ValueError("""Input list must be a non empty list"""						)
 UpperCAmelCase	:					Any	=	0
 for val in series:
  answer += val
 return answer / len(UpperCamelCase						)


if __name__ == "__main__":
      import doctest

      doctest.testmod()
