






"""simple docstring"""



from io import BytesIO
from typing import List, Union

import requests

from ..utils import add_end_docstrings, is_decord_available, is_torch_available, logging, requires_backends
from .base import PIPELINE_INIT_ARGS, Pipeline


if is_decord_available():
						import numpy as np
						from decord import VideoReader


if is_torch_available():
						from ..models.auto.modeling_auto import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING

A__			:							str					   =   logging.get_logger(__name__)







@add_end_docstrings(SCREAMING_SNAKE_CASE_  )
class   lowercase__     (				SCREAMING_SNAKE_CASE_  ):


			def __init__( self	:    Optional[Any]  ,			*snake_case__	:    Any  ,			**snake_case__	:    Optional[Any]   ):
										super().__init__(*lowercase_  ,			**lowercase_   )
										requires_backends(self  ,			"decord"   )
										self.check_model_type(lowercase_   )


			def       UpperCAmelCase__		( self	:    Optional[Any]  ,			snake_case__	:    List[str]=None  ,			snake_case__	:    List[Any]=None  ,			snake_case__	:    int=None   ):
										lowerCamelCase_			:				List[Any]										={}
										if frame_sampling_rate is not None:
																	lowerCamelCase_			:				int										=frame_sampling_rate
										if num_frames is not None:
																	lowerCamelCase_			:				Dict										=num_frames

										lowerCamelCase_			:				Optional[Any]										={}
										if top_k is not None:
																	lowerCamelCase_			:				Union[str, Any]										=top_k
										return preprocess_params, {}, postprocess_params


			def __call__( self	:    Any  ,			snake_case__	:    List[Any]  ,			**snake_case__	:    Union[str, Any]   ):
										return super().__call__(lowercase_  ,			**lowercase_   )


			def       UpperCAmelCase__		( self	:    Optional[int]  ,			snake_case__	:    int  ,			snake_case__	:    str=None  ,			snake_case__	:    List[str]=1   ):
										if num_frames is None:
																	lowerCamelCase_			:				List[Any]										=self.model.config.num_frames

										if video.startswith("http://"   ) or video.startswith("https://"   ):
																	lowerCamelCase_			:				Optional[Any]										=BytesIO(requests.get(lowercase_   ).content   )

										lowerCamelCase_			:				List[str]										=VideoReader(lowercase_   )
										videoreader.seek(0   )

										lowerCamelCase_			:				Any										=0
										lowerCamelCase_			:				Tuple										=num_frames * frame_sampling_rate - 1
										lowerCamelCase_			:				List[Any]										=np.linspace(lowercase_  ,			lowercase_  ,			num=lowercase_  ,			dtype=np.intaa   )

										lowerCamelCase_			:				int										=videoreader.get_batch(lowercase_   ).asnumpy()
										lowerCamelCase_			:				List[str]										=list(lowercase_   )

										lowerCamelCase_			:				int										=self.image_processor(lowercase_  ,			return_tensors=self.framework   )
										return model_inputs


			def       UpperCAmelCase__		( self	:    List[Any]  ,			snake_case__	:    List[str]   ):
										lowerCamelCase_			:				Optional[int]										=self.model(**lowercase_   )
										return model_outputs


			def       UpperCAmelCase__		( self	:    List[Any]  ,			snake_case__	:    Union[str, Any]  ,			snake_case__	:    Optional[int]=5   ):
										if top_k > self.model.config.num_labels:
																	lowerCamelCase_			:				List[Any]										=self.model.config.num_labels

										if self.framework == "pt":
																	lowerCamelCase_			:				Union[str, Any]										=model_outputs.logits.softmax(-1   )[0]
																	lowerCamelCase_				,		lowerCamelCase_			:				int										=probs.topk(lowercase_   )
										else:
																	raise ValueError(F"""Unsupported framework: {self.framework}"""   )

										lowerCamelCase_			:				List[str]										=scores.tolist()
										lowerCamelCase_			:				Dict										=ids.tolist()
										return [{"score": score, "label": self.model.config.idalabel[_id]} for score, _id in zip(lowercase_  ,			lowercase_   )]





"""simple docstring"""

def      lowercase__    (       lowerCAmelCase					:       str			)			->   bool:






    """simple docstring"""




    UpperCAmelCase          =       [int(lowerCAmelCase			) for i in ip_va_address.split('.'			) if i.isdigit()]
    return len(lowerCAmelCase			) == 4 and all(0 <= int(lowerCAmelCase			) <= 254 for octet in octets			)


if __name__ == "__main__":
   SCREAMING_SNAKE_CASE_            =    input().strip()
   SCREAMING_SNAKE_CASE_            =    '''valid''' if is_ip_va_address_valid(ip) else '''invalid'''
   print(F'{ip} is a {valid_or_invalid} IP v4 address.')



