




'''simple docstring'''
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


A							:				int			     =	1_000






class 	SCREAMING_SNAKE_CASE:

       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 ,		)   -> Tuple:

           """simple docstring"""



           if isinstance(lowerCamelCase__ ,		torch.Tensor					):
               __lowercase          =						img.numpy().astype("""np.uint8"""					)
           if isinstance(lowerCamelCase__ ,		lowerCamelCase__					):
               __lowercase          =						img_tensorize(lowerCamelCase__					)
           assert isinstance(lowerCamelCase__ ,		np.ndarray					)

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

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

       def    snake_case__      (   self ,		lowerCamelCase__ ,		lowerCamelCase__=None					)   -> List[str]:

           """simple docstring"""



           if color is None:
               __lowercase          =						self.edgecolor
           ((__lowercase)    ,(__lowercase)    ,(__lowercase)    ,(__lowercase))          =						box
           __lowercase          =						xa - xa
           __lowercase          =						ya - ya
           self.ax.add_patch(
               mpl.patches.Rectangle(
                   (xa, ya) ,		lowerCamelCase__ ,		lowerCamelCase__ ,		fill=lowerCamelCase__ ,		edgecolor=lowerCamelCase__ ,		linewidth=self.font_size // 3 ,		alpha=self.alpha ,		linestyle=self.linestyle ,		)					)

       def    snake_case__      (   self ,		lowerCamelCase__ ,		lowerCamelCase__=None ,		lowerCamelCase__=None ,		lowerCamelCase__=None ,		lowerCamelCase__=None					)   -> Union[str, Any]:

           """simple docstring"""



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

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

       def    snake_case__      (   self ,		lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__					)   -> List[str]:

           """simple docstring"""



           __lowercase    ,__lowercase    ,__lowercase    ,__lowercase          =						box
           __lowercase          =						(xa, ya)
           __lowercase          =						(ya - ya) * (xa - xa)
           __lowercase          =						_SMALL_OBJ * self.scale
           if instance_area < small or ya - ya < 40 * self.scale:
               if ya >= self.height - 5:
                   __lowercase          =						(xa, ya)
               else:
                   __lowercase          =						(xa, ya)

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

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

       def    snake_case__      (   self ,		lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__="g" ,		lowerCamelCase__="left" ,		)   -> Tuple:

           """simple docstring"""



           __lowercase          =						0
           __lowercase          =						self.font_size
           __lowercase          =						np.maximum(list(mplc.to_rgb(lowerCamelCase__					)					) ,		0.2					)
           __lowercase          =						max(0.8 ,		np.max(lowerCamelCase__					)					)
           __lowercase          =						{
               """facecolor""": """black""",
               """alpha""": self.alpha,
               """pad""": self.pad,
               """edgecolor""": """none""",
           }
           __lowercase    ,__lowercase          =						position
           self.ax.text(
               lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__ ,		size=font_size * self.scale ,		family="""sans-serif""" ,		bbox=lowerCamelCase__ ,		verticalalignment="""top""" ,		horizontalalignment=lowerCamelCase__ ,		color=lowerCamelCase__ ,		zorder=10 ,		rotation=lowerCamelCase__ ,		)

       def    snake_case__      (   self ,		lowerCamelCase__=None					)   -> int:

           """simple docstring"""



           if saveas is None:
               __lowercase          =						self.saveas
           if saveas.lower().endswith(""".jpg"""					) or saveas.lower().endswith(""".png"""					):
               cva.imwrite(
                   lowerCamelCase__ ,		self._get_buffer()[:, :, ::-1] ,		)
           else:
               self.fig.savefig(lowerCamelCase__					)

       def    snake_case__      (   self ,		lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__					)   -> str:

           """simple docstring"""



           __lowercase          =						[self.idaobj[i] for i in classes]
           __lowercase          =						[self.idaattr[i] for i in attr_classes]
           __lowercase          =						[
               F'{label} {score:.2f} {attr} {attr_score:.2f}'
               for label, score, attr, attr_score in zip(lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__ ,		lowerCamelCase__					)
           ]
           return labels

       def    snake_case__      (   self ,		lowerCamelCase__ ,		lowerCamelCase__					)   -> Dict:

           """simple docstring"""



           __lowercase          =						[self.idaobj[i] for i in classes]
           if scores is not None:
               if labels is None:
                   __lowercase          =						["""{:.0f}%""".format(s * 100					) for s in scores]
               else:
                   __lowercase          =						["""{} {:.0f}%""".format(lowerCamelCase__ ,		s * 100					) for li, s in zip(lowerCamelCase__ ,		lowerCamelCase__					)]
           return labels

       def    snake_case__      (   self ,		lowerCamelCase__=255					)   -> Optional[int]:

           """simple docstring"""



           __lowercase          =						np.random.randint(0 ,		len(_COLORS					)					)
           __lowercase          =						_COLORS[idx] * maximum
           if not self.rgb:
               __lowercase          =						ret[::-1]
           return ret

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

           """simple docstring"""



           if not self.pynb:
               __lowercase    ,__lowercase          =						self.canvas.print_to_buffer()
               if (width, height) != (self.width, self.height):
                   __lowercase          =						cva.resize(self.img ,		(width, height)					)
               else:
                   __lowercase          =						self.img
           else:
               __lowercase          =						io.BytesIO()  # works for cairo backend
               self.canvas.print_rgba(lowerCamelCase__					)
               __lowercase    ,__lowercase          =						self.width, self.height
               __lowercase          =						buf.getvalue()
               __lowercase          =						self.img

           __lowercase          =						np.frombuffer(lowerCamelCase__ ,		dtype="""uint8"""					)
           __lowercase          =						buffer.reshape(lowerCamelCase__ ,		lowerCamelCase__ ,		4					)
           __lowercase    ,__lowercase          =						np.split(lowerCamelCase__ ,		[3] ,		axis=2					)

           try:
               import numexpr as ne  # fuse them with numexpr

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

           return visualized_image.astype("""uint8"""					)




       def    snake_case__      (   self ,		lowerCamelCase__ ,		lowerCamelCase__					)   -> Dict:

           """simple docstring"""



           assert brightness_factor >= -1.0 and brightness_factor <= 1.0
           __lowercase          =						mplc.to_rgb(lowerCamelCase__					)
           __lowercase          =						colorsys.rgb_to_hls(*mplc.to_rgb(lowerCamelCase__					)					)
           __lowercase          =						polygon_color[1] + (brightness_factor * polygon_color[1])
           __lowercase          =						0.0 if modified_lightness < 0.0 else modified_lightness
           __lowercase          =						1.0 if modified_lightness > 1.0 else modified_lightness
           __lowercase          =						colorsys.hls_to_rgb(polygon_color[0] ,		lowerCamelCase__ ,		polygon_color[2]					)
           return modified_color

A							:				List[Any]			     =	(
    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 copy import deepcopy
from unittest.case import TestCase

import pytest

from datasets.arrow_dataset import Dataset
from datasets.features import Audio, ClassLabel, Features, Image, Sequence, Value
from datasets.info import DatasetInfo
from datasets.tasks import (
    AudioClassification,
    AutomaticSpeechRecognition,
    ImageClassification,
    LanguageModeling,
    QuestionAnsweringExtractive,
    Summarization,
    TextClassification,
    task_template_from_dict,
)
from datasets.utils.py_utils import asdict


A							:				Dict			     =	{
    """id""": """5733be284776f41900661182""",
    """title""": """University_of_Notre_Dame""",
    """context""": """Architecturally, the school has a Catholic character. Atop the Main Building\'s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend \"Venite Ad Me Omnes\". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary.""",
    """question""": """To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?""",
    """answers""": {"""text""": ["""Saint Bernadette Soubirous"""], """answer_start""": [515]},
}
@pytest.mark.parametrize(
    """task_cls"""   ,[
        AudioClassification,
        AutomaticSpeechRecognition,
        ImageClassification,
        LanguageModeling,
        QuestionAnsweringExtractive,
        Summarization,
        TextClassification,
    ]   ,)
def     snake_case_  (       a__		:     str      ):



    """simple docstring"""




    __lowercase          =						task_cls()
    __lowercase          =						asdict(a__      )
    __lowercase          =						task_template_from_dict(a__      )
    assert task == reloaded






class 	SCREAMING_SNAKE_CASE:

       def    snake_case__      (   self					)   -> Any:

           """simple docstring"""



           __lowercase          =						LanguageModeling(text_column="""input_text"""					)
           assert {"input_text": "text"} == task.column_mapping




       def    snake_case__      (   self					)   -> Any:

           """simple docstring"""



           __lowercase          =						Features({"""text""": Value("""string"""					)}					)
           __lowercase          =						{"""text_column""": """input_text"""}
           __lowercase          =						LanguageModeling.from_dict(lowerCamelCase__					)
           assert "language-modeling" == task.task
           assert input_schema == task.input_schema






class 	SCREAMING_SNAKE_CASE(    __A					):

       def    snake_case__      (   self					)   -> Dict:

           """simple docstring"""



           __lowercase          =						sorted(["""pos""", """neg"""]					)

       def    snake_case__      (   self					)   -> Tuple:

           """simple docstring"""



           __lowercase          =						TextClassification(text_column="""input_text""" ,		label_column="""input_label"""					)
           self.assertDictEqual({"""input_text""": """text""", """input_label""": """labels"""} ,		task.column_mapping					)

       def    snake_case__      (   self					)   -> Dict:

           """simple docstring"""



           __lowercase          =						Features({"""text""": Value("""string"""					)}					)
           # Labels are cast to tuple during `TextClassification.__post_init__`, so we do the same here
           __lowercase          =						Features({"""labels""": ClassLabel}					)
           __lowercase          =						{"""text_column""": """input_text""", """label_column""": """input_labels"""}
           __lowercase          =						TextClassification.from_dict(lowerCamelCase__					)
           self.assertEqual("""text-classification""" ,		task.task					)
           self.assertEqual(lowerCamelCase__ ,		task.input_schema					)
           self.assertEqual(lowerCamelCase__ ,		task.label_schema					)




       def    snake_case__      (   self					)   -> str:

           """simple docstring"""



           __lowercase          =						TextClassification(text_column="""input_text""" ,		label_column="""input_label"""					)
           self.assertEqual(task.label_schema["""labels"""] ,		lowerCamelCase__					)
           __lowercase          =						task.align_with_features(Features({"""input_label""": ClassLabel(names=self.labels					)}					)					)
           self.assertEqual(task.label_schema["""labels"""] ,		ClassLabel(names=self.labels					)					)






class 	SCREAMING_SNAKE_CASE(    __A					):

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

           """simple docstring"""



           __lowercase          =						QuestionAnsweringExtractive(
               context_column="""input_context""" ,		question_column="""input_question""" ,		answers_column="""input_answers"""					)
           self.assertDictEqual(
               {"""input_context""": """context""", """input_question""": """question""", """input_answers""": """answers"""} ,		task.column_mapping					)




       def    snake_case__      (   self					)   -> Dict:

           """simple docstring"""



           __lowercase          =						Features({"""question""": Value("""string"""					), """context""": Value("""string"""					)}					)
           __lowercase          =						Features(
               {
                   """answers""": Sequence(
                       {
                           """text""": Value("""string"""					),
                           """answer_start""": Value("""int32"""					),
                       }					)
               }					)
           __lowercase          =						{
               """context_column""": """input_input_context""",
               """question_column""": """input_question""",
               """answers_column""": """input_answers""",
           }
           __lowercase          =						QuestionAnsweringExtractive.from_dict(lowerCamelCase__					)
           self.assertEqual("""question-answering-extractive""" ,		task.task					)
           self.assertEqual(lowerCamelCase__ ,		task.input_schema					)
           self.assertEqual(lowerCamelCase__ ,		task.label_schema					)






class 	SCREAMING_SNAKE_CASE(    __A					):

       def    snake_case__      (   self					)   -> int:

           """simple docstring"""



           __lowercase          =						Summarization(text_column="""input_text""" ,		summary_column="""input_summary"""					)
           self.assertDictEqual({"""input_text""": """text""", """input_summary""": """summary"""} ,		task.column_mapping					)




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

           """simple docstring"""



           __lowercase          =						Features({"""text""": Value("""string"""					)}					)
           __lowercase          =						Features({"""summary""": Value("""string"""					)}					)
           __lowercase          =						{"""text_column""": """input_text""", """summary_column""": """input_summary"""}
           __lowercase          =						Summarization.from_dict(lowerCamelCase__					)
           self.assertEqual("""summarization""" ,		task.task					)
           self.assertEqual(lowerCamelCase__ ,		task.input_schema					)
           self.assertEqual(lowerCamelCase__ ,		task.label_schema					)






class 	SCREAMING_SNAKE_CASE(    __A					):

       def    snake_case__      (   self					)   -> str:

           """simple docstring"""



           __lowercase          =						AutomaticSpeechRecognition(audio_column="""input_audio""" ,		transcription_column="""input_transcription"""					)
           self.assertDictEqual({"""input_audio""": """audio""", """input_transcription""": """transcription"""} ,		task.column_mapping					)




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

           """simple docstring"""



           __lowercase          =						Features({"""audio""": Audio()}					)
           __lowercase          =						Features({"""transcription""": Value("""string"""					)}					)
           __lowercase          =						{
               """audio_column""": """input_audio""",
               """transcription_column""": """input_transcription""",
           }
           __lowercase          =						AutomaticSpeechRecognition.from_dict(lowerCamelCase__					)
           self.assertEqual("""automatic-speech-recognition""" ,		task.task					)
           self.assertEqual(lowerCamelCase__ ,		task.input_schema					)
           self.assertEqual(lowerCamelCase__ ,		task.label_schema					)






class 	SCREAMING_SNAKE_CASE(    __A					):

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

           """simple docstring"""



           __lowercase          =						sorted(["""pos""", """neg"""]					)

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

           """simple docstring"""



           __lowercase          =						AudioClassification(audio_column="""input_audio""" ,		label_column="""input_label"""					)
           self.assertDictEqual({"""input_audio""": """audio""", """input_label""": """labels"""} ,		task.column_mapping					)

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

           """simple docstring"""



           __lowercase          =						Features({"""audio""": Audio()}					)
           __lowercase          =						Features({"""labels""": ClassLabel}					)
           __lowercase          =						{
               """audio_column""": """input_image""",
               """label_column""": """input_label""",
           }
           __lowercase          =						AudioClassification.from_dict(lowerCamelCase__					)
           self.assertEqual("""audio-classification""" ,		task.task					)
           self.assertEqual(lowerCamelCase__ ,		task.input_schema					)
           self.assertEqual(lowerCamelCase__ ,		task.label_schema					)




       def    snake_case__      (   self					)   -> str:

           """simple docstring"""



           __lowercase          =						AudioClassification(audio_column="""input_audio""" ,		label_column="""input_label"""					)
           self.assertEqual(task.label_schema["""labels"""] ,		lowerCamelCase__					)
           __lowercase          =						task.align_with_features(Features({"""input_label""": ClassLabel(names=self.labels					)}					)					)
           self.assertEqual(task.label_schema["""labels"""] ,		ClassLabel(names=self.labels					)					)






class 	SCREAMING_SNAKE_CASE(    __A					):

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

           """simple docstring"""



           __lowercase          =						sorted(["""pos""", """neg"""]					)

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

           """simple docstring"""



           __lowercase          =						ImageClassification(image_column="""input_image""" ,		label_column="""input_label"""					)
           self.assertDictEqual({"""input_image""": """image""", """input_label""": """labels"""} ,		task.column_mapping					)

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

           """simple docstring"""



           __lowercase          =						Features({"""image""": Image()}					)
           __lowercase          =						Features({"""labels""": ClassLabel}					)
           __lowercase          =						{
               """image_column""": """input_image""",
               """label_column""": """input_label""",
           }
           __lowercase          =						ImageClassification.from_dict(lowerCamelCase__					)
           self.assertEqual("""image-classification""" ,		task.task					)
           self.assertEqual(lowerCamelCase__ ,		task.input_schema					)
           self.assertEqual(lowerCamelCase__ ,		task.label_schema					)




       def    snake_case__      (   self					)   -> Tuple:

           """simple docstring"""



           __lowercase          =						ImageClassification(image_column="""input_image""" ,		label_column="""input_label"""					)
           self.assertEqual(task.label_schema["""labels"""] ,		lowerCamelCase__					)
           __lowercase          =						task.align_with_features(Features({"""input_label""": ClassLabel(names=self.labels					)}					)					)
           self.assertEqual(task.label_schema["""labels"""] ,		ClassLabel(names=self.labels					)					)






class 	SCREAMING_SNAKE_CASE(    __A					):

       def    snake_case__      (   self					)   -> Tuple:

           """simple docstring"""



           __lowercase          =						DatasetInfo(task_templates=QuestionAnsweringExtractive()					)
           __lowercase          =						Dataset.from_dict({k: [v] for k, v in SAMPLE_QUESTION_ANSWERING_EXTRACTIVE.items()} ,		info=lowerCamelCase__					)
           assert isinstance(dataset.info.task_templates ,		lowerCamelCase__					)
           assert len(dataset.info.task_templates					) == 1

           def keep_task(lowerCamelCase__					):
               return x

           def dont_keep_task(lowerCamelCase__					):
               __lowercase          =						deepcopy(lowerCamelCase__					)
               __lowercase          =						0
               return out

           __lowercase          =						dataset.map(lowerCamelCase__					)
           assert mapped_dataset.info.task_templates == dataset.info.task_templates
           # reload from cache
           __lowercase          =						dataset.map(lowerCamelCase__					)
           assert mapped_dataset.info.task_templates == dataset.info.task_templates

           __lowercase          =						dataset.map(lowerCamelCase__					)
           assert mapped_dataset.info.task_templates == []
           # reload from cache
           __lowercase          =						dataset.map(lowerCamelCase__					)
           assert mapped_dataset.info.task_templates == []




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

           """simple docstring"""



           __lowercase          =						Features({"""text""": Value("""string"""					), """label""": ClassLabel(names=("""pos""", """neg""")					)}					)
           __lowercase          =						TextClassification(text_column="""text""" ,		label_column="""label"""					)
           __lowercase          =						DatasetInfo(features=lowerCamelCase__ ,		task_templates=lowerCamelCase__					)
           __lowercase          =						Dataset.from_dict({"""text""": ["""A sentence."""], """label""": ["""pos"""]} ,		info=lowerCamelCase__					)

           def process(lowerCamelCase__					):
               return example

           __lowercase          =						dataset.remove_columns("""label"""					)
           __lowercase          =						modified_dataset.map(lowerCamelCase__					)
           assert mapped_dataset.info.task_templates == []




