






"""simple docstring"""







from typing import List, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...utils import logging


a			:    Dict				 =		logging.get_logger(__name__)

a			:    List[Any]				 =		{
    """huggingface/informer-tourism-monthly""": (
        """https://huggingface.co/huggingface/informer-tourism-monthly/resolve/main/config.json"""
    ),
    # See all Informer models at https://huggingface.co/models?filter=informer
}


class    __UpperCAmelCase(       SCREAMING_SNAKE_CASE__							):




						"""simple docstring"""




						__lowerCamelCase    	= "informer"
						__lowerCamelCase    	= {
						    "hidden_size": "d_model",
						    "num_attention_heads": "encoder_attention_heads",
						    "num_hidden_layers": "encoder_layers",
						}




						def __init__(       self	,  snake_case__ = None	,  snake_case__ = None	,  snake_case__ = "student_t"	,  snake_case__ = "nll"	,  snake_case__ = 1	,  snake_case__ = None	,  snake_case__ = "mean"	,  snake_case__ = 0	,  snake_case__ = 0	,  snake_case__ = 0	,  snake_case__ = 0	,  snake_case__ = None	,  snake_case__ = None	,  snake_case__ = 64	,  snake_case__ = 32	,  snake_case__ = 32	,  snake_case__ = 2	,  snake_case__ = 2	,  snake_case__ = 2	,  snake_case__ = 2	,  snake_case__ = True	,  snake_case__ = "gelu"	,  snake_case__ = 0.05	,  snake_case__ = 0.1	,  snake_case__ = 0.1	,  snake_case__ = 0.1	,  snake_case__ = 0.1	,  snake_case__ = 100	,  snake_case__ = 0.02	,  snake_case__=True	,  snake_case__ = "prob"	,  snake_case__ = 5	,  snake_case__ = True	,  **snake_case__	,  ):
												'''simple docstring'''
												# time series specific configuration
												lowercase__    :				Dict=	prediction_length
												lowercase__    :				List[Any]=	context_length or prediction_length
												lowercase__    :				Dict=	distribution_output
												lowercase__    :				Dict=	loss
												lowercase__    :				str=	input_size
												lowercase__    :				Any=	num_time_features
												lowercase__    :				int=	lags_sequence if lags_sequence is not None else [1, 2, 3, 4, 5, 6, 7]
												lowercase__    :				int=	scaling
												lowercase__    :				List[Any]=	num_dynamic_real_features
												lowercase__    :				Dict=	num_static_real_features
												lowercase__    :				Dict=	num_static_categorical_features

												# set cardinality
												if cardinality and num_static_categorical_features > 0:
																		if len(snake_case__      ) != num_static_categorical_features:
																								raise ValueError(
																								    "The cardinality should be a list of the same length as `num_static_categorical_features`"      )
																		lowercase__    :				Union[str, Any]=	cardinality
												else:
																		lowercase__    :				Any=	[0]

												# set embedding_dimension
												if embedding_dimension and num_static_categorical_features > 0:
																		if len(snake_case__      ) != num_static_categorical_features:
																								raise ValueError(
																								    "The embedding dimension should be a list of the same length as `num_static_categorical_features`"      )
																		lowercase__    :				Any=	embedding_dimension
												else:
																		lowercase__    :				Tuple=	[min(50	,  (cat + 1) // 2      ) for cat in self.cardinality]

												lowercase__    :				Union[str, Any]=	num_parallel_samples

												# Transformer architecture configuration
												lowercase__    :				Optional[int]=	input_size * len(self.lags_sequence      ) + self._number_of_features
												lowercase__    :				Dict=	d_model
												lowercase__    :				Dict=	encoder_attention_heads
												lowercase__    :				str=	decoder_attention_heads
												lowercase__    :				List[Any]=	encoder_ffn_dim
												lowercase__    :				Tuple=	decoder_ffn_dim
												lowercase__    :				Union[str, Any]=	encoder_layers
												lowercase__    :				Optional[int]=	decoder_layers

												lowercase__    :				Tuple=	dropout
												lowercase__    :				Optional[Any]=	attention_dropout
												lowercase__    :				Optional[int]=	activation_dropout
												lowercase__    :				Optional[Any]=	encoder_layerdrop
												lowercase__    :				List[Any]=	decoder_layerdrop

												lowercase__    :				List[Any]=	activation_function
												lowercase__    :				Dict=	init_std

												lowercase__    :				List[str]=	use_cache

												# Informer
												lowercase__    :				Union[str, Any]=	attention_type
												lowercase__    :				Any=	sampling_factor
												lowercase__    :				Optional[Any]=	distil

												super().__init__(is_encoder_decoder=snake_case__	,  **snake_case__      )




						@property
						def 		UpperCAmelCase_	(       self      ):
												'''simple docstring'''
												return (
												    sum(self.embedding_dimension      )
												    + self.num_dynamic_real_features
												    + self.num_time_features
												    + self.num_static_real_features
												    + self.input_size * 2  # the log1p(abs(loc)) and log(scale) features
												)














"""simple docstring"""







from collections import defaultdict
from pathlib import Path

import pandas as pd
from rouge_cli import calculate_rouge_path

from utils import calculate_rouge


a			:    Optional[Any]				 =		[
    """Prosecutor: \"No videos were used in the crash investigation\" German papers say they saw a cell phone video of the"""
    """ final seconds on board Flight 9525. The Germanwings co-pilot says he had a \"previous episode of severe"""
    """ depression\" German airline confirms it knew of Andreas Lubitz's depression years before he took control.""",
    """The Palestinian Authority officially becomes the 123rd member of the International Criminal Court. The formal"""
    """ accession was marked with a ceremony at The Hague, in the Netherlands. The Palestinians signed the ICC's"""
    """ founding Rome Statute in January. Israel and the United States opposed the Palestinians' efforts to join the"""
    """ body.""",
    """Amnesty International releases its annual report on the death penalty. The report catalogs the use of"""
    """ state-sanctioned killing as a punitive measure across the globe. At least 607 people were executed around the"""
    """ world in 2014, compared to 778 in 2013. The U.S. remains one of the worst offenders for imposing capital"""
    """ punishment.""",
]

a			:    str				 =		[
    """Marseille prosecutor says \"so far no videos were used in the crash investigation\" despite media reports ."""
    """ Journalists at Bild and Paris Match are \"very confident\" the video clip is real, an editor says . Andreas Lubitz"""
    """ had informed his Lufthansa training school of an episode of severe depression, airline says .""",
    """Membership gives the ICC jurisdiction over alleged crimes committed in Palestinian territories since last June ."""
    """ Israel and the United States opposed the move, which could open the door to war crimes investigations against"""
    """ Israelis .""",
    """Amnesty's annual death penalty report catalogs encouraging signs, but setbacks in numbers of those sentenced to"""
    """ death . Organization claims that governments around the world are using the threat of terrorism to advance"""
    """ executions . The number of executions worldwide has gone down by almost 22% compared with 2013, but death"""
    """ sentences up by 28% .""",
]





def 						lowercase__()    ->List[Any]:




						"""simple docstring"""



						lowercase__    :				str=	calculate_rouge(A ,		A ,		bootstrap_aggregation=A ,		rouge_keys=["rouge2", "rougeL"]						)
						assert isinstance(A ,		A						)
						lowercase__    :				Optional[int]=	calculate_rouge(A ,		A ,		bootstrap_aggregation=A ,		rouge_keys=["rouge2"]						)
						assert (
						    pd.DataFrame(no_aggregation["rouge2"]						).fmeasure.mean()
						    == pd.DataFrame(no_aggregation_just_ra["rouge2"]						).fmeasure.mean()
						)





def 						lowercase__()    ->int:




						"""simple docstring"""



						lowercase__    :				Optional[int]=	"rougeLsum"
						lowercase__    :				str=	calculate_rouge(A ,		A ,		newline_sep=A ,		rouge_keys=[k]						)[k]
						lowercase__    :				Union[str, Any]=	calculate_rouge(A ,		A ,		newline_sep=A ,		rouge_keys=[k]						)[k]
						assert score > score_no_sep





def 						lowercase__()    ->Tuple:




						"""simple docstring"""



						lowercase__    :				Tuple=	["rouge1", "rouge2", "rougeL"]
						lowercase__    :				Optional[Any]=	calculate_rouge(A ,		A ,		newline_sep=A ,		rouge_keys=A						)
						lowercase__    :				Dict=	calculate_rouge(A ,		A ,		newline_sep=A ,		rouge_keys=A						)
						assert score_sep == score_no_sep





def 						lowercase__()    ->Optional[int]:




						"""simple docstring"""



						lowercase__    :				int=	[
						    "Her older sister, Margot Frank, died in 1945, a month earlier than previously thought.",
						    "Marseille prosecutor says \"so far no videos were used in the crash investigation\" despite media reports .",
						]
						lowercase__    :				Dict=	[
						    "Margot Frank, died in 1945, a month earlier than previously thought.",
						    "Prosecutor: \"No videos were used in the crash investigation\" German papers say they saw a cell phone video of"
						    " the final seconds on board Flight 9525.",
						]
						assert calculate_rouge(A ,		A ,		newline_sep=A						) == calculate_rouge(A ,		A ,		newline_sep=A						)





def 						lowercase__()    ->Dict:




						"""simple docstring"""



						lowercase__    :				List[str]=	[
						    "\" \"a person who has such a video needs to immediately give it to the investigators,\" prosecutor says .<n> \"it is a very disturbing scene,\" editor-in-chief of bild online tells \"erin burnett: outfront\" "
						]
						lowercase__    :				Union[str, Any]=	[
						    " Marseille prosecutor says \"so far no videos were used in the crash investigation\" despite media reports . Journalists at Bild and Paris Match are \"very confident\" the video clip is real, an editor says . Andreas Lubitz had informed his Lufthansa training school of an episode of severe depression, airline says ."
						]

						lowercase__    :				List[Any]=	calculate_rouge(A ,		A ,		rouge_keys=["rougeLsum"] ,		newline_sep=A						)["rougeLsum"]
						lowercase__    :				Optional[Any]=	calculate_rouge(A ,		A ,		rouge_keys=["rougeLsum"]						)["rougeLsum"]
						assert new_score > prev_score







def 						lowercase__()    ->Optional[Any]:




						"""simple docstring"""



						lowercase__    :				Optional[Any]=	Path("examples/seq2seq/test_data/wmt_en_ro"						)
						lowercase__    :				Union[str, Any]=	calculate_rouge_path(data_dir.joinpath("test.source"						) ,		data_dir.joinpath("test.target"						)						)
						assert isinstance(A ,		A						)
						lowercase__    :				List[Any]=	calculate_rouge_path(
						    data_dir.joinpath("test.source"						) ,		data_dir.joinpath("test.target"						) ,		bootstrap_aggregation=A						)
						assert isinstance(A ,		A						)






