





import json
import os
from collections import Counter

import torch
import torchvision
import torchvision.transforms as transforms
from PIL import Image
from torch import nn
from torch.utils.data import Dataset


__UpperCAmelCase					:     List[str]	      =	{1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1), 6: (3, 2), 7: (7, 1), 8: (4, 2), 9: (3, 3)}


class 			lowerCamelCase						(		nn.Module  ):







  def __init__(     self						:   Dict  ,					__snake_case						:   Optional[int]       )    ->		List[str]:
        super().__init__()
        _a							:  Any				= torchvision.models.resnetaaa(pretrained=__lowerCamelCase       )
        _a							:  Union[str, Any]				= list(model.children()       )[:-2]
        _a							:  int				= nn.Sequential(*__lowerCamelCase       )
        _a							:  List[Any]				= nn.AdaptiveAvgPoolad(POOLING_BREAKDOWN[args.num_image_embeds]       )







  def      snake_case_							(     self						:   Optional[int]  ,					__snake_case						:   Dict       )    ->		Union[str, Any]:
        _a							:  Tuple				= self.pool(self.model(__lowerCamelCase       )       )
        _a							:  List[Any]				= torch.flatten(__lowerCamelCase  ,					start_dim=2       )
        _a							:  Optional[Any]				= out.transpose(1  ,					2       ).contiguous()
        return out  # BxNx2048


class 			lowerCamelCase						(		SCREAMING_SNAKE_CASE__  ):







  def __init__(     self						:   Dict  ,					__snake_case						:   List[str]  ,					__snake_case						:   str  ,					__snake_case						:   str  ,					__snake_case						:   List[str]  ,					__snake_case						:   str       )    ->		Dict:
        _a							:  Union[str, Any]				= [json.loads(__lowerCamelCase       ) for l in open(__lowerCamelCase       )]
        _a							:  int				= os.path.dirname(__lowerCamelCase       )
        _a							:  Optional[int]				= tokenizer
        _a							:  Any				= labels
        _a							:  str				= len(__lowerCamelCase       )
        _a							:  List[str]				= max_seq_length

        _a							:  Dict				= transforms







  def __len__(     self						:   List[str]       )    ->		Dict:
        return len(self.data       )







  def __getitem__(     self						:   List[Any]  ,					__snake_case						:   Optional[Any]       )    ->		List[str]:
        _a							:  str				= torch.LongTensor(self.tokenizer.encode(self.data[index]['''text''']  ,					add_special_tokens=__lowerCamelCase       )       )
        _a							:  List[Any]				= sentence[0], sentence[1:-1], sentence[-1]
        _a							:  int				= sentence[: self.max_seq_length]

        _a							:  Union[str, Any]				= torch.zeros(self.n_classes       )
        _a							:  int				= 1

        _a							:  Tuple				= Image.open(os.path.join(self.data_dir  ,					self.data[index]['''img''']       )       ).convert('''RGB'''       )
        _a							:  Optional[int]				= self.transforms(__lowerCamelCase       )

        return {
            "image_start_token": start_token,
            "image_end_token": end_token,
            "sentence": sentence,
            "image": image,
            "label": label,
        }







  def      snake_case_							(     self						:   List[str]       )    ->		List[Any]:
        _a							:  List[Any]				= Counter()
        for row in self.data:
              label_freqs.update(row['''label''']       )
        return label_freqs




def 						lowerCamelCase_	(		UpperCamelCase_       ):
      _a							:  Optional[Any]				= [len(row['''sentence''']       ) for row in batch]
      _a							:  Tuple				= len(snake_case_       ), max(snake_case_       )

      _a							:  int				= torch.zeros(snake_case_			,					snake_case_			,					dtype=torch.long       )
      _a							:  Optional[Any]				= torch.zeros(snake_case_			,					snake_case_			,					dtype=torch.long       )

      for i_batch, (input_row, length) in enumerate(zip(snake_case_			,					snake_case_       )       ):
            _a							:  Tuple				= input_row['''sentence''']
            _a							:  List[Any]				= 1

      _a							:  Any				= torch.stack([row['''image'''] for row in batch]       )
      _a							:  int				= torch.stack([row['''label'''] for row in batch]       )
      _a							:  List[str]				= torch.stack([row['''image_start_token'''] for row in batch]       )
      _a							:  List[Any]				= torch.stack([row['''image_end_token'''] for row in batch]       )

      return text_tensor, mask_tensor, img_tensor, img_start_token, img_end_token, tgt_tensor




def 						lowerCamelCase_	(		):
      return [
          "Crime",
          "Drama",
          "Thriller",
          "Action",
          "Comedy",
          "Romance",
          "Documentary",
          "Short",
          "Mystery",
          "History",
          "Family",
          "Adventure",
          "Fantasy",
          "Sci-Fi",
          "Western",
          "Horror",
          "Sport",
          "War",
          "Music",
          "Musical",
          "Animation",
          "Biography",
          "Film-Noir",
      ]





def 						lowerCamelCase_	(		):
      return transforms.Compose(
          [
              transforms.Resize(256       ),
              transforms.CenterCrop(224       ),
              transforms.ToTensor(),
              transforms.Normalize(
                  mean=[0.46777044, 0.44531429, 0.40661017]			,					std=[0.12221994, 0.12145835, 0.14380469]			,					),
          ]       )












"""simple docstring"""



def 						__lowercase	(  snake_case_    :    int		)  ->int:



    '''simple docstring'''







    __A       :		str							=	1
    for i in range(1							,num + 1		):
        fact *= i
    return fact







def 						__lowercase	(  snake_case_    :    int		)  ->int:



    '''simple docstring'''







    __A       :		str							=	0
    while number > 0:
        __A       :		Optional[int]							=	number % 10
        sum_of_digits += last_digit
        __A       :		Dict							=	number // 10  # Removing the last_digit from the given number
    return sum_of_digits







def 						__lowercase	(  snake_case_    :    int = 100		)  ->int:



    '''simple docstring'''







    __A       :		Optional[int]							=	factorial(snake_case_		)
    __A       :		Optional[Any]							=	split_and_add(snake_case_		)
    return result


if __name__ == "__main__":
       print(solution(int(input("""Enter the Number: """).strip())))




