





import colorsys
import io

import cva
import matplotlib as mpl
import matplotlib.colors as mplc
import matplotlib.figure as mplfigure
import numpy as np
import torch
from matplotlib.backends.backend_agg import FigureCanvasAgg

from utils import img_tensorize


UpperCAmelCase_   				=  1000
class       UpperCamelCase_		:




					def __init__(		self					,    lowerCAmelCase_					,    lowerCAmelCase_=1.2					,    lowerCAmelCase_="g"					,    lowerCAmelCase_=0.5					,    lowerCAmelCase_="-"					,    lowerCAmelCase_="test_out.jpg"					,    lowerCAmelCase_=True					,    lowerCAmelCase_=False					,    lowerCAmelCase_=None					,    lowerCAmelCase_=None					,    lowerCAmelCase_=0.7					,    )		->				int:
										if isinstance(SCREAMING_SNAKE_CASE_					,    torch.Tensor	):
															_snake_case						=					img.numpy().astype('np.uint8'	)
										if isinstance(SCREAMING_SNAKE_CASE_					,    SCREAMING_SNAKE_CASE_	):
															_snake_case						=					img_tensorize(SCREAMING_SNAKE_CASE_	)
										assert isinstance(SCREAMING_SNAKE_CASE_					,    np.ndarray	)

										_snake_case						=					img.shape[1], img.shape[0]
										_snake_case						=					mplfigure.Figure(frameon=SCREAMING_SNAKE_CASE_	)
										_snake_case						=					fig.get_dpi()
										_snake_case						=					(width * scale + 1E-2) / dpi
										_snake_case						=					(height * scale + 1E-2) / dpi
										fig.set_size_inches(SCREAMING_SNAKE_CASE_					,    SCREAMING_SNAKE_CASE_	)
										_snake_case						=					fig.add_axes([0.0, 0.0, 1.0, 1.0]	)
										ax.axis('off'	)
										ax.set_xlim(0.0					,    SCREAMING_SNAKE_CASE_	)
										ax.set_ylim(SCREAMING_SNAKE_CASE_	)

										_snake_case						=					saveas
										_snake_case						=					rgb
										_snake_case						=					pynb
										_snake_case						=					img
										_snake_case						=					edgecolor
										_snake_case						=					0.5
										_snake_case						=					linestyle
										_snake_case						=					int(np.sqrt(min(SCREAMING_SNAKE_CASE_					,    SCREAMING_SNAKE_CASE_	)	) * scale // 3	)
										_snake_case						=					width
										_snake_case						=					height
										_snake_case						=					scale
										_snake_case						=					fig
										_snake_case						=					ax
										_snake_case						=					pad
										_snake_case						=					idaobj
										_snake_case						=					idaattr
										_snake_case						=					FigureCanvasAgg(SCREAMING_SNAKE_CASE_	)




					def 						lowerCAmelCase      (		self					,    lowerCAmelCase_					,    lowerCAmelCase_=None	)		->				List[str]:
										if color is None:
															_snake_case						=					self.edgecolor
										(_snake_case)						=					box
										_snake_case						=					xa - xa
										_snake_case						=					ya - ya
										self.ax.add_patch(
										    mpl.patches.Rectangle(
										        (xa, ya)					,    SCREAMING_SNAKE_CASE_					,    SCREAMING_SNAKE_CASE_					,    fill=SCREAMING_SNAKE_CASE_					,    edgecolor=SCREAMING_SNAKE_CASE_					,    linewidth=self.font_size // 3					,    alpha=self.alpha					,    linestyle=self.linestyle					,    )	)




					def 						lowerCAmelCase      (		self					,    lowerCAmelCase_					,    lowerCAmelCase_=None					,    lowerCAmelCase_=None					,    lowerCAmelCase_=None					,    lowerCAmelCase_=None	)		->				int:
										if len(boxes.shape	) > 2:
															_snake_case						=					boxes[0]
										if len(obj_ids.shape	) > 1:
															_snake_case						=					obj_ids[0]
										if len(obj_scores.shape	) > 1:
															_snake_case						=					obj_scores[0]
										if len(attr_ids.shape	) > 1:
															_snake_case						=					attr_ids[0]
										if len(attr_scores.shape	) > 1:
															_snake_case						=					attr_scores[0]
										if isinstance(SCREAMING_SNAKE_CASE_					,    torch.Tensor	):
															_snake_case						=					boxes.numpy()
										if isinstance(SCREAMING_SNAKE_CASE_					,    SCREAMING_SNAKE_CASE_	):
															_snake_case						=					np.array(SCREAMING_SNAKE_CASE_	)
										assert isinstance(SCREAMING_SNAKE_CASE_					,    np.ndarray	)
										_snake_case						=					np.prod(boxes[:, 2:] - boxes[:, :2]					,    axis=1	)
										_snake_case						=					np.argsort(-areas	).tolist()
										_snake_case						=					boxes[sorted_idxs] if boxes is not None else None
										_snake_case						=					obj_ids[sorted_idxs] if obj_ids is not None else None
										_snake_case						=					obj_scores[sorted_idxs] if obj_scores is not None else None
										_snake_case						=					attr_ids[sorted_idxs] if attr_ids is not None else None
										_snake_case						=					attr_scores[sorted_idxs] if attr_scores is not None else None

										_snake_case						=					[self._random_color(maximum=1	) for _ in range(len(SCREAMING_SNAKE_CASE_	)	)]
										_snake_case						=					[assigned_colors[idx] for idx in sorted_idxs]
										if obj_ids is not None:
															_snake_case						=					self._create_text_labels_attr(SCREAMING_SNAKE_CASE_					,    SCREAMING_SNAKE_CASE_					,    SCREAMING_SNAKE_CASE_					,    SCREAMING_SNAKE_CASE_	)
															for i in range(len(SCREAMING_SNAKE_CASE_	)	):
																				_snake_case						=					assigned_colors[i]
																				self.add_box(boxes[i]					,    SCREAMING_SNAKE_CASE_	)
																				self.draw_labels(labels[i]					,    boxes[i]					,    SCREAMING_SNAKE_CASE_	)




					def 						lowerCAmelCase      (		self					,    lowerCAmelCase_					,    lowerCAmelCase_					,    lowerCAmelCase_	)		->				List[str]:
										_snake_case						=					box
										_snake_case						=					(xa, ya)
										_snake_case						=					(ya - ya) * (xa - xa)
										_snake_case						=					_SMALL_OBJ * self.scale
										if instance_area < small or ya - ya < 40 * self.scale:
															if ya >= self.height - 5:
																				_snake_case						=					(xa, ya)
															else:
																				_snake_case						=					(xa, ya)

										_snake_case						=					(ya - ya) / np.sqrt(self.height * self.width	)
										_snake_case						=					self._change_color_brightness(SCREAMING_SNAKE_CASE_					,    brightness_factor=0.7	)
										_snake_case						=					np.clip((height_ratio - 0.02) / 0.08 + 1					,    1.2					,    2	)
										font_size *= 0.75 * self.font_size

										self.draw_text(
										    text=SCREAMING_SNAKE_CASE_					,    position=SCREAMING_SNAKE_CASE_					,    color=SCREAMING_SNAKE_CASE_					,    )




					def 						lowerCAmelCase      (		self					,    lowerCAmelCase_					,    lowerCAmelCase_					,    lowerCAmelCase_="g"					,    lowerCAmelCase_="left"					,    )		->				List[Any]:
										_snake_case						=					0
										_snake_case						=					self.font_size
										_snake_case						=					np.maximum(list(mplc.to_rgb(SCREAMING_SNAKE_CASE_	)	)					,    0.2	)
										_snake_case						=					max(0.8					,    np.max(SCREAMING_SNAKE_CASE_	)	)
										_snake_case						=					{
										    '''facecolor''': '''black''',
										    '''alpha''': self.alpha,
										    '''pad''': self.pad,
										    '''edgecolor''': '''none''',
										}
										_snake_case						=					position
										self.ax.text(
										    SCREAMING_SNAKE_CASE_					,    SCREAMING_SNAKE_CASE_					,    SCREAMING_SNAKE_CASE_					,    size=font_size * self.scale					,    family='sans-serif'					,    bbox=SCREAMING_SNAKE_CASE_					,    verticalalignment='top'					,    horizontalalignment=SCREAMING_SNAKE_CASE_					,    color=SCREAMING_SNAKE_CASE_					,    zorder=10					,    rotation=SCREAMING_SNAKE_CASE_					,    )




					def 						lowerCAmelCase      (		self					,    lowerCAmelCase_=None	)		->				Any:
										if saveas is None:
															_snake_case						=					self.saveas
										if saveas.lower().endswith('.jpg'	) or saveas.lower().endswith('.png'	):
															cva.imwrite(
															    SCREAMING_SNAKE_CASE_					,    self._get_buffer()[:, :, ::-1]					,    )
										else:
															self.fig.savefig(SCREAMING_SNAKE_CASE_	)




					def 						lowerCAmelCase      (		self					,    lowerCAmelCase_					,    lowerCAmelCase_					,    lowerCAmelCase_					,    lowerCAmelCase_	)		->				Tuple:
										_snake_case						=					[self.idaobj[i] for i in classes]
										_snake_case						=					[self.idaattr[i] for i in attr_classes]
										_snake_case						=					[
										    F'''{label} {score:.2f} {attr} {attr_score:.2f}'''
										    for label, score, attr, attr_score in zip(SCREAMING_SNAKE_CASE_					,    SCREAMING_SNAKE_CASE_					,    SCREAMING_SNAKE_CASE_					,    SCREAMING_SNAKE_CASE_	)
										]
										return labels




					def 						lowerCAmelCase      (		self					,    lowerCAmelCase_					,    lowerCAmelCase_	)		->				List[str]:
										_snake_case						=					[self.idaobj[i] for i in classes]
										if scores is not None:
															if labels is None:
																				_snake_case						=					['''{:.0f}%'''.format(s * 100	) for s in scores]
															else:
																				_snake_case						=					['''{} {:.0f}%'''.format(SCREAMING_SNAKE_CASE_					,    s * 100	) for li, s in zip(SCREAMING_SNAKE_CASE_					,    SCREAMING_SNAKE_CASE_	)]
										return labels




					def 						lowerCAmelCase      (		self					,    lowerCAmelCase_=255	)		->				int:
										_snake_case						=					np.random.randint(0					,    len(_COLORS	)	)
										_snake_case						=					_COLORS[idx] * maximum
										if not self.rgb:
															_snake_case						=					ret[::-1]
										return ret




					def 						lowerCAmelCase      (		self	)		->				List[Any]:
										if not self.pynb:
															_snake_case						=					self.canvas.print_to_buffer()
															if (width, height) != (self.width, self.height):
																				_snake_case						=					cva.resize(self.img					,    (width, height)	)
															else:
																				_snake_case						=					self.img
										else:
															_snake_case						=					io.BytesIO()  # works for cairo backend
															self.canvas.print_rgba(SCREAMING_SNAKE_CASE_	)
															_snake_case						=					self.width, self.height
															_snake_case						=					buf.getvalue()
															_snake_case						=					self.img

										_snake_case						=					np.frombuffer(SCREAMING_SNAKE_CASE_					,    dtype='uint8'	)
										_snake_case						=					buffer.reshape(SCREAMING_SNAKE_CASE_					,    SCREAMING_SNAKE_CASE_					,    4	)
										_snake_case						=					np.split(SCREAMING_SNAKE_CASE_					,    [3]					,    axis=2	)

										try:
															import numexpr as ne  # fuse them with numexpr

															_snake_case						=					ne.evaluate('img * (1 - alpha / 255.0) + rgb * (alpha / 255.0)'	)
										except ImportError:
															_snake_case						=					alpha.astype('float32'	) / 2_55.0
															_snake_case						=					img * (1 - alpha) + rgb * alpha

										return visualized_image.astype('uint8'	)






					def 						lowerCAmelCase      (		self					,    lowerCAmelCase_					,    lowerCAmelCase_	)		->				Union[str, Any]:
										assert brightness_factor >= -1.0 and brightness_factor <= 1.0
										_snake_case						=					mplc.to_rgb(SCREAMING_SNAKE_CASE_	)
										_snake_case						=					colorsys.rgb_to_hls(*mplc.to_rgb(SCREAMING_SNAKE_CASE_	)	)
										_snake_case						=					polygon_color[1] + (brightness_factor * polygon_color[1])
										_snake_case						=					0.0 if modified_lightness < 0.0 else modified_lightness
										_snake_case						=					1.0 if modified_lightness > 1.0 else modified_lightness
										_snake_case						=					colorsys.hls_to_rgb(polygon_color[0]					,    SCREAMING_SNAKE_CASE_					,    polygon_color[2]	)
										return modified_color





UpperCAmelCase_   				=  (
    np.array(
        [
            0.0_00,
            0.4_47,
            0.7_41,
            0.8_50,
            0.3_25,
            0.0_98,
            0.9_29,
            0.6_94,
            0.1_25,
            0.4_94,
            0.1_84,
            0.5_56,
            0.4_66,
            0.6_74,
            0.1_88,
            0.3_01,
            0.7_45,
            0.9_33,
            0.6_35,
            0.0_78,
            0.1_84,
            0.3_00,
            0.3_00,
            0.3_00,
            0.6_00,
            0.6_00,
            0.6_00,
            1.0_00,
            0.0_00,
            0.0_00,
            1.0_00,
            0.5_00,
            0.0_00,
            0.7_49,
            0.7_49,
            0.0_00,
            0.0_00,
            1.0_00,
            0.0_00,
            0.0_00,
            0.0_00,
            1.0_00,
            0.6_67,
            0.0_00,
            1.0_00,
            0.3_33,
            0.3_33,
            0.0_00,
            0.3_33,
            0.6_67,
            0.0_00,
            0.3_33,
            1.0_00,
            0.0_00,
            0.6_67,
            0.3_33,
            0.0_00,
            0.6_67,
            0.6_67,
            0.0_00,
            0.6_67,
            1.0_00,
            0.0_00,
            1.0_00,
            0.3_33,
            0.0_00,
            1.0_00,
            0.6_67,
            0.0_00,
            1.0_00,
            1.0_00,
            0.0_00,
            0.0_00,
            0.3_33,
            0.5_00,
            0.0_00,
            0.6_67,
            0.5_00,
            0.0_00,
            1.0_00,
            0.5_00,
            0.3_33,
            0.0_00,
            0.5_00,
            0.3_33,
            0.3_33,
            0.5_00,
            0.3_33,
            0.6_67,
            0.5_00,
            0.3_33,
            1.0_00,
            0.5_00,
            0.6_67,
            0.0_00,
            0.5_00,
            0.6_67,
            0.3_33,
            0.5_00,
            0.6_67,
            0.6_67,
            0.5_00,
            0.6_67,
            1.0_00,
            0.5_00,
            1.0_00,
            0.0_00,
            0.5_00,
            1.0_00,
            0.3_33,
            0.5_00,
            1.0_00,
            0.6_67,
            0.5_00,
            1.0_00,
            1.0_00,
            0.5_00,
            0.0_00,
            0.3_33,
            1.0_00,
            0.0_00,
            0.6_67,
            1.0_00,
            0.0_00,
            1.0_00,
            1.0_00,
            0.3_33,
            0.0_00,
            1.0_00,
            0.3_33,
            0.3_33,
            1.0_00,
            0.3_33,
            0.6_67,
            1.0_00,
            0.3_33,
            1.0_00,
            1.0_00,
            0.6_67,
            0.0_00,
            1.0_00,
            0.6_67,
            0.3_33,
            1.0_00,
            0.6_67,
            0.6_67,
            1.0_00,
            0.6_67,
            1.0_00,
            1.0_00,
            1.0_00,
            0.0_00,
            1.0_00,
            1.0_00,
            0.3_33,
            1.0_00,
            1.0_00,
            0.6_67,
            1.0_00,
            0.3_33,
            0.0_00,
            0.0_00,
            0.5_00,
            0.0_00,
            0.0_00,
            0.6_67,
            0.0_00,
            0.0_00,
            0.8_33,
            0.0_00,
            0.0_00,
            1.0_00,
            0.0_00,
            0.0_00,
            0.0_00,
            0.1_67,
            0.0_00,
            0.0_00,
            0.3_33,
            0.0_00,
            0.0_00,
            0.5_00,
            0.0_00,
            0.0_00,
            0.6_67,
            0.0_00,
            0.0_00,
            0.8_33,
            0.0_00,
            0.0_00,
            1.0_00,
            0.0_00,
            0.0_00,
            0.0_00,
            0.1_67,
            0.0_00,
            0.0_00,
            0.3_33,
            0.0_00,
            0.0_00,
            0.5_00,
            0.0_00,
            0.0_00,
            0.6_67,
            0.0_00,
            0.0_00,
            0.8_33,
            0.0_00,
            0.0_00,
            1.0_00,
            0.0_00,
            0.0_00,
            0.0_00,
            0.1_43,
            0.1_43,
            0.1_43,
            0.8_57,
            0.8_57,
            0.8_57,
            1.0_00,
            1.0_00,
            1.0_00,
        ]
    )
    .astype(np.floataa)
    .reshape(-1, 3)
)









"""simple docstring"""





from typing import TYPE_CHECKING

from ..utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available


_lowercase						   =     {
    """configuration_utils""": ["""GenerationConfig"""],
    """streamers""": ["""TextIteratorStreamer""", """TextStreamer"""],
}

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							_lowercase						   =     [
							    """Constraint""",
							    """ConstraintListState""",
							    """DisjunctiveConstraint""",
							    """PhrasalConstraint""",
							]
							_lowercase						   =     [
							    """BeamHypotheses""",
							    """BeamScorer""",
							    """BeamSearchScorer""",
							    """ConstrainedBeamSearchScorer""",
							]
							_lowercase						   =     [
							    """EpsilonLogitsWarper""",
							    """EtaLogitsWarper""",
							    """ForcedBOSTokenLogitsProcessor""",
							    """ForcedEOSTokenLogitsProcessor""",
							    """HammingDiversityLogitsProcessor""",
							    """InfNanRemoveLogitsProcessor""",
							    """LogitsProcessor""",
							    """LogitsProcessorList""",
							    """LogitsWarper""",
							    """MinLengthLogitsProcessor""",
							    """MinNewTokensLengthLogitsProcessor""",
							    """NoBadWordsLogitsProcessor""",
							    """NoRepeatNGramLogitsProcessor""",
							    """PrefixConstrainedLogitsProcessor""",
							    """RepetitionPenaltyLogitsProcessor""",
							    """SequenceBiasLogitsProcessor""",
							    """EncoderRepetitionPenaltyLogitsProcessor""",
							    """TemperatureLogitsWarper""",
							    """TopKLogitsWarper""",
							    """TopPLogitsWarper""",
							    """TypicalLogitsWarper""",
							    """EncoderNoRepeatNGramLogitsProcessor""",
							    """ExponentialDecayLengthPenalty""",
							    """LogitNormalization""",
							]
							_lowercase						   =     [
							    """MaxNewTokensCriteria""",
							    """MaxLengthCriteria""",
							    """MaxTimeCriteria""",
							    """StoppingCriteria""",
							    """StoppingCriteriaList""",
							    """validate_stopping_criteria""",
							]
							_lowercase						   =     [
							    """GenerationMixin""",
							    """top_k_top_p_filtering""",
							    """GreedySearchEncoderDecoderOutput""",
							    """GreedySearchDecoderOnlyOutput""",
							    """SampleEncoderDecoderOutput""",
							    """SampleDecoderOnlyOutput""",
							    """BeamSearchEncoderDecoderOutput""",
							    """BeamSearchDecoderOnlyOutput""",
							    """BeamSampleEncoderDecoderOutput""",
							    """BeamSampleDecoderOnlyOutput""",
							    """ContrastiveSearchEncoderDecoderOutput""",
							    """ContrastiveSearchDecoderOnlyOutput""",
							]

try:
							if not is_tf_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							_lowercase						   =     [
							    """TFForcedBOSTokenLogitsProcessor""",
							    """TFForcedEOSTokenLogitsProcessor""",
							    """TFLogitsProcessor""",
							    """TFLogitsProcessorList""",
							    """TFLogitsWarper""",
							    """TFMinLengthLogitsProcessor""",
							    """TFNoBadWordsLogitsProcessor""",
							    """TFNoRepeatNGramLogitsProcessor""",
							    """TFRepetitionPenaltyLogitsProcessor""",
							    """TFTemperatureLogitsWarper""",
							    """TFTopKLogitsWarper""",
							    """TFTopPLogitsWarper""",
							    """TFForceTokensLogitsProcessor""",
							    """TFSuppressTokensAtBeginLogitsProcessor""",
							    """TFSuppressTokensLogitsProcessor""",
							]
							_lowercase						   =     [
							    """TFGenerationMixin""",
							    """tf_top_k_top_p_filtering""",
							    """TFGreedySearchDecoderOnlyOutput""",
							    """TFGreedySearchEncoderDecoderOutput""",
							    """TFSampleEncoderDecoderOutput""",
							    """TFSampleDecoderOnlyOutput""",
							    """TFBeamSearchEncoderDecoderOutput""",
							    """TFBeamSearchDecoderOnlyOutput""",
							    """TFBeamSampleEncoderDecoderOutput""",
							    """TFBeamSampleDecoderOnlyOutput""",
							    """TFContrastiveSearchEncoderDecoderOutput""",
							    """TFContrastiveSearchDecoderOnlyOutput""",
							]

try:
							if not is_flax_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							_lowercase						   =     [
							    """FlaxForcedBOSTokenLogitsProcessor""",
							    """FlaxForcedEOSTokenLogitsProcessor""",
							    """FlaxLogitsProcessor""",
							    """FlaxLogitsProcessorList""",
							    """FlaxLogitsWarper""",
							    """FlaxMinLengthLogitsProcessor""",
							    """FlaxTemperatureLogitsWarper""",
							    """FlaxTopKLogitsWarper""",
							    """FlaxTopPLogitsWarper""",
							]
							_lowercase						   =     [
							    """FlaxGenerationMixin""",
							    """FlaxGreedySearchOutput""",
							    """FlaxSampleOutput""",
							    """FlaxBeamSearchOutput""",
							]

if TYPE_CHECKING:
							from .configuration_utils import GenerationConfig
							from .streamers import TextIteratorStreamer, TextStreamer

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .beam_constraints import Constraint, ConstraintListState, DisjunctiveConstraint, PhrasalConstraint
														from .beam_search import BeamHypotheses, BeamScorer, BeamSearchScorer, ConstrainedBeamSearchScorer
														from .logits_process import (
														    EncoderNoRepeatNGramLogitsProcessor,
														    EncoderRepetitionPenaltyLogitsProcessor,
														    EpsilonLogitsWarper,
														    EtaLogitsWarper,
														    ExponentialDecayLengthPenalty,
														    ForcedBOSTokenLogitsProcessor,
														    ForcedEOSTokenLogitsProcessor,
														    HammingDiversityLogitsProcessor,
														    InfNanRemoveLogitsProcessor,
														    LogitNormalization,
														    LogitsProcessor,
														    LogitsProcessorList,
														    LogitsWarper,
														    MinLengthLogitsProcessor,
														    MinNewTokensLengthLogitsProcessor,
														    NoBadWordsLogitsProcessor,
														    NoRepeatNGramLogitsProcessor,
														    PrefixConstrainedLogitsProcessor,
														    RepetitionPenaltyLogitsProcessor,
														    SequenceBiasLogitsProcessor,
														    TemperatureLogitsWarper,
														    TopKLogitsWarper,
														    TopPLogitsWarper,
														    TypicalLogitsWarper,
														)
														from .stopping_criteria import (
														    MaxLengthCriteria,
														    MaxNewTokensCriteria,
														    MaxTimeCriteria,
														    StoppingCriteria,
														    StoppingCriteriaList,
														    validate_stopping_criteria,
														)
														from .utils import (
														    BeamSampleDecoderOnlyOutput,
														    BeamSampleEncoderDecoderOutput,
														    BeamSearchDecoderOnlyOutput,
														    BeamSearchEncoderDecoderOutput,
														    ContrastiveSearchDecoderOnlyOutput,
														    ContrastiveSearchEncoderDecoderOutput,
														    GenerationMixin,
														    GreedySearchDecoderOnlyOutput,
														    GreedySearchEncoderDecoderOutput,
														    SampleDecoderOnlyOutput,
														    SampleEncoderDecoderOutput,
														    top_k_top_p_filtering,
														)

							try:
														if not is_tf_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .tf_logits_process import (
														    TFForcedBOSTokenLogitsProcessor,
														    TFForcedEOSTokenLogitsProcessor,
														    TFForceTokensLogitsProcessor,
														    TFLogitsProcessor,
														    TFLogitsProcessorList,
														    TFLogitsWarper,
														    TFMinLengthLogitsProcessor,
														    TFNoBadWordsLogitsProcessor,
														    TFNoRepeatNGramLogitsProcessor,
														    TFRepetitionPenaltyLogitsProcessor,
														    TFSuppressTokensAtBeginLogitsProcessor,
														    TFSuppressTokensLogitsProcessor,
														    TFTemperatureLogitsWarper,
														    TFTopKLogitsWarper,
														    TFTopPLogitsWarper,
														)
														from .tf_utils import (
														    TFBeamSampleDecoderOnlyOutput,
														    TFBeamSampleEncoderDecoderOutput,
														    TFBeamSearchDecoderOnlyOutput,
														    TFBeamSearchEncoderDecoderOutput,
														    TFContrastiveSearchDecoderOnlyOutput,
														    TFContrastiveSearchEncoderDecoderOutput,
														    TFGenerationMixin,
														    TFGreedySearchDecoderOnlyOutput,
														    TFGreedySearchEncoderDecoderOutput,
														    TFSampleDecoderOnlyOutput,
														    TFSampleEncoderDecoderOutput,
														    tf_top_k_top_p_filtering,
														)

							try:
														if not is_flax_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .flax_logits_process import (
														    FlaxForcedBOSTokenLogitsProcessor,
														    FlaxForcedEOSTokenLogitsProcessor,
														    FlaxLogitsProcessor,
														    FlaxLogitsProcessorList,
														    FlaxLogitsWarper,
														    FlaxMinLengthLogitsProcessor,
														    FlaxTemperatureLogitsWarper,
														    FlaxTopKLogitsWarper,
														    FlaxTopPLogitsWarper,
														)
														from .flax_utils import FlaxBeamSearchOutput, FlaxGenerationMixin, FlaxGreedySearchOutput, FlaxSampleOutput
else:
							import sys

							_lowercase						   =     _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


