'''simple docstring'''

import json
import os
import pickle
import subprocess
from hashlib import mda
from pathlib import Path
from tempfile import gettempdir
from textwrap import dedent
from types import CodeType, FunctionType
from unittest import TestCase
from unittest.mock import patch

import pytest
from multiprocess import Pool
from packaging import version

import datasets
from datasets.fingerprint import Hasher, fingerprint_transform
from datasets.table import InMemoryTable

from .utils import (
    require_regex,
    require_spacy,
    require_spacy_model,
    require_tiktoken,
    require_torch,
    require_transformers,
)





class 				lowercase    :


   def __init__( self					:						Optional[Any] ,		__lowerCAmelCase					:						Optional[Any])   ->       Optional[Any]:
         lowercase_     			=   foo


   def __call__( self					:						str)   ->       Tuple:
         return self.foo





class 				lowercase    (    datasets.Dataset			):


   @fingerprint_transform(inplace=__lowerCAmelCase)
   def __UpperCAmelCase							( self					:						List[Any] ,		__lowerCAmelCase					:						List[Any] ,		*__lowerCAmelCase					:						str ,		**__lowerCAmelCase					:						Dict)   ->       List[str]:
         return DatasetChild(self.data ,		fingerprint=__lowerCAmelCase)


   @fingerprint_transform(inplace=__lowerCAmelCase)
   def __UpperCAmelCase							( self					:						Tuple ,		__lowerCAmelCase					:						str ,		*__lowerCAmelCase					:						Tuple ,		**__lowerCAmelCase					:						Dict)   ->       Dict:
         return DatasetChild(self.data ,		fingerprint=__lowerCAmelCase)





class 				lowercase    :


   def __init__( self					:						Any ,		__lowerCAmelCase					:						Union[str, Any])   ->       Union[str, Any]:
         lowercase_     			=   callable


   def __call__( self					:						str ,		*__lowerCAmelCase					:						Union[str, Any] ,		**__lowerCAmelCase					:						Optional[Any])   ->       str:
         if self.callable is not None:
               return self.callable(*__lowerCAmelCase ,		**__lowerCAmelCase)


   def __getstate__( self					:						Optional[Any])   ->       Tuple:
         raise pickle.PicklingError()





class 				lowercase    (    __lowerCamelCase			):


   @require_transformers
   @pytest.mark.integration
   def __UpperCAmelCase							( self					:						int)   ->       Optional[Any]:
         from transformers import AutoTokenizer

         def encode(__lowerCAmelCase					:						Union[str, Any]):
               return tokenizer(__lowerCAmelCase)

         # TODO: add hash consistency tests across sessions
         lowercase_     			=   AutoTokenizer.from_pretrained("bert-base-uncased")
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(lambda __lowerCAmelCase: tokenizer(__lowerCAmelCase))).hexdigest()
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         lowercase_     			=   AutoTokenizer.from_pretrained("bert-base-cased")
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(lambda __lowerCAmelCase: tokenizer(__lowerCAmelCase))).hexdigest()
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         lowercase_     			=   AutoTokenizer.from_pretrained("bert-base-uncased")
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(lambda __lowerCAmelCase: tokenizer(__lowerCAmelCase))).hexdigest()
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertNotEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertNotEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertNotEqual(__lowerCAmelCase ,		__lowerCAmelCase)


   @require_transformers
   @pytest.mark.integration
   def __UpperCAmelCase							( self					:						int)   ->       Any:
         from transformers import AutoTokenizer

         lowercase_     			=   AutoTokenizer.from_pretrained("gpt2")
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         tokenizer("Hello world !")  # call once to change the tokenizer's cache
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)


   @require_regex
   def __UpperCAmelCase							( self					:						Tuple)   ->       int:
         import regex

         lowercase_     			=   regex.Regex("foo")
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         lowercase_     			=   regex.Regex("bar")
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         lowercase_     			=   regex.Regex("foo")
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertNotEqual(__lowerCAmelCase ,		__lowerCAmelCase)





class 				lowercase    (    __lowerCamelCase			):


   def __UpperCAmelCase							( self					:						List[str])   ->       Union[str, Any]:
         def func():
               return foo

         lowercase_     			=   [0]
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         lowercase_     			=   [1]
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         lowercase_     			=   [0]
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertNotEqual(__lowerCAmelCase ,		__lowerCAmelCase)


   def __UpperCAmelCase							( self					:						Optional[Any])   ->       Union[str, Any]:
         def func():
               pass

         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()

         def func():
               pass

         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)


   def __UpperCAmelCase							( self					:						List[str])   ->       Tuple:
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(Foo([0]))).hexdigest()
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(Foo([1]))).hexdigest()
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(Foo([0]))).hexdigest()
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertNotEqual(__lowerCAmelCase ,		__lowerCAmelCase)


   def __UpperCAmelCase							( self					:						List[str])   ->       Optional[Any]:
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(Foo([0]).__call__)).hexdigest()
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(Foo([1]).__call__)).hexdigest()
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(Foo([0]).__call__)).hexdigest()
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertNotEqual(__lowerCAmelCase ,		__lowerCAmelCase)


   def __UpperCAmelCase							( self					:						Optional[Any])   ->       str:
         lowercase_     			=   (
             "co_argcount",
             "co_kwonlyargcount",
             "co_nlocals",
             "co_stacksize",
             "co_flags",
             "co_code",
             "co_consts",
             "co_names",
             "co_varnames",
             "co_filename",
             "co_name",
             "co_firstlineno",
             "co_lnotab",
             "co_freevars",
             "co_cellvars",
         )

         def _create_code_pyaa(*__lowerCAmelCase					:						Optional[int]):
               if hasattr(args[-3] ,		"encode"):
                     lowercase_     			=   list(__lowerCAmelCase)
                     lowercase_     			=   args[-3].encode()  # co_lnotab
                     lowercase_     			=   args[-10].encode()  # co_code
               if hasattr(__lowerCAmelCase ,		"co_posonlyargcount"):
                     if len(__lowerCAmelCase) == 16:
                           return CodeType(*__lowerCAmelCase)
                     elif len(__lowerCAmelCase) == 15:
                           return CodeType(args[0] ,		0 ,		*args[1:])
                     return CodeType(args[0] ,		0 ,		0 ,		*args[1:])
               elif hasattr(__lowerCAmelCase ,		"co_kwonlyargcount"):
                     if len(__lowerCAmelCase) == 16:
                           return CodeType(args[0] ,		*args[2:])
                     elif len(__lowerCAmelCase) == 15:
                           return CodeType(*__lowerCAmelCase)
                     return CodeType(args[0] ,		0 ,		*args[1:])
               if len(__lowerCAmelCase) == 16:
                     return CodeType(args[0] ,		*args[3:])
               elif len(__lowerCAmelCase) == 15:
                     return CodeType(args[0] ,		*args[2:])
               return CodeType(*__lowerCAmelCase)

         def create_ipython_func(__lowerCAmelCase					:						List[Any] ,		__lowerCAmelCase					:						Dict):
               def func():
                     return returned_obj

               lowercase_     			=   func.__code__
               # Use _create_code from dill in order to make it work for different python versions
               if datasets.config.PY_VERSION < version.parse("3.8"):
                     lowercase_     			=   _create_code_pyaa(
                         *[getattr(__lowerCAmelCase ,		__lowerCAmelCase) if k != "co_filename" else co_filename for k in code_args_pyaa])
               else:
                     lowercase_     			=   code.replace(co_filename=__lowerCAmelCase)
               return FunctionType(__lowerCAmelCase ,		func.__globals__ ,		func.__name__ ,		func.__defaults__ ,		func.__closure__)

         lowercase_			,				lowercase_     			=   "<ipython-input-2-e0383a102aae>", [0]
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(create_ipython_func(__lowerCAmelCase ,		__lowerCAmelCase))).hexdigest()
         lowercase_			,				lowercase_     			=   "<ipython-input-2-e0383a102aae>", [1]
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(create_ipython_func(__lowerCAmelCase ,		__lowerCAmelCase))).hexdigest()
         lowercase_			,				lowercase_     			=   "<ipython-input-5-713f6613acf3>", [0]
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(create_ipython_func(__lowerCAmelCase ,		__lowerCAmelCase))).hexdigest()
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertNotEqual(__lowerCAmelCase ,		__lowerCAmelCase)

         lowercase_			,				lowercase_     			=   os.path.join(gettempdir() ,		"ipykernel_12345" ,		"321456789.py"), [0]
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(create_ipython_func(__lowerCAmelCase ,		__lowerCAmelCase))).hexdigest()
         lowercase_			,				lowercase_     			=   os.path.join(gettempdir() ,		"ipykernel_12345" ,		"321456789.py"), [1]
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(create_ipython_func(__lowerCAmelCase ,		__lowerCAmelCase))).hexdigest()
         lowercase_			,				lowercase_     			=   os.path.join(gettempdir() ,		"ipykernel_12345" ,		"654123987.py"), [0]
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(create_ipython_func(__lowerCAmelCase ,		__lowerCAmelCase))).hexdigest()
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertNotEqual(__lowerCAmelCase ,		__lowerCAmelCase)


   def __UpperCAmelCase							( self					:						int)   ->       Tuple:
         lowercase_			,				lowercase_     			=   [0], [1]

         def func():
               return foo, bar

         lowercase_     			=   "__main__"

         def globalvars_mocka_side_effect(__lowerCAmelCase					:						Dict ,		*__lowerCAmelCase					:						Any ,		**__lowerCAmelCase					:						str):
               return {"foo": foo, "bar": bar}

         def globalvars_mocka_side_effect(__lowerCAmelCase					:						int ,		*__lowerCAmelCase					:						List[Any] ,		**__lowerCAmelCase					:						List[Any]):
               return {"bar": bar, "foo": foo}

         with patch("dill.detect.globalvars" ,		side_effect=__lowerCAmelCase) as globalvars_mocka:
               lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
               self.assertGreater(globalvars_mocka.call_count ,		0)
         with patch("dill.detect.globalvars" ,		side_effect=__lowerCAmelCase) as globalvars_mocka:
               lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
               self.assertGreater(globalvars_mocka.call_count ,		0)
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)





class 				lowercase    (    __lowerCamelCase			):


   def __UpperCAmelCase							( self					:						Optional[int])   ->       Tuple:
         lowercase_     			=   Hasher.hash("hello")
         lowercase_     			=   Hasher.hash("hello")
         lowercase_     			=   Hasher.hash("there")
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertNotEqual(__lowerCAmelCase ,		__lowerCAmelCase)


   def __UpperCAmelCase							( self					:						Tuple)   ->       int:
         lowercase_     			=   Hasher.hash(Foo("hello"))
         lowercase_     			=   Hasher.hash(Foo("hello"))
         lowercase_     			=   Hasher.hash(Foo("there"))
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertNotEqual(__lowerCAmelCase ,		__lowerCAmelCase)


   def __UpperCAmelCase							( self					:						List[Any])   ->       Tuple:
         lowercase_     			=   Hasher()
         for x in ["hello", Foo("hello")]:
               hasher.update(__lowerCAmelCase)
         lowercase_     			=   hasher.hexdigest()
         lowercase_     			=   Hasher()
         for x in ["hello", Foo("hello")]:
               hasher.update(__lowerCAmelCase)
         lowercase_     			=   hasher.hexdigest()
         lowercase_     			=   Hasher()
         for x in ["there", Foo("there")]:
               hasher.update(__lowerCAmelCase)
         lowercase_     			=   hasher.hexdigest()
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertNotEqual(__lowerCAmelCase ,		__lowerCAmelCase)


   def __UpperCAmelCase							( self					:						Optional[Any])   ->       Union[str, Any]:
         with self.assertRaises(pickle.PicklingError):
               Hasher.hash(UnpicklableCallable(Foo("hello")))


   def __UpperCAmelCase							( self					:						Tuple)   ->       int:
         lowercase_     			=   "abc"
         lowercase_     			=   [string, string]  # two strings have the same ids
         lowercase_     			=   [string, string]
         lowercase_     			=   json.loads(F'["{string}", "{string}"]')  # two strings have different ids
         self.assertIs(obja[0] ,		__lowerCAmelCase)
         self.assertIs(obja[0] ,		obja[1])
         self.assertIs(obja[0] ,		__lowerCAmelCase)
         self.assertIs(obja[0] ,		obja[1])
         self.assertIsNot(obja[0] ,		__lowerCAmelCase)
         self.assertIsNot(obja[0] ,		obja[1])
         lowercase_     			=   Hasher.hash(__lowerCAmelCase)
         lowercase_     			=   Hasher.hash(__lowerCAmelCase)
         lowercase_     			=   Hasher.hash(__lowerCAmelCase)
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)


   @require_tiktoken
   def __UpperCAmelCase							( self					:						List[str])   ->       Union[str, Any]:
         import tiktoken

         lowercase_     			=   tiktoken.get_encoding("gpt2")
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         lowercase_     			=   tiktoken.get_encoding("r50k_base")
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         lowercase_     			=   tiktoken.get_encoding("gpt2")
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertNotEqual(__lowerCAmelCase ,		__lowerCAmelCase)


   @require_torch
   def __UpperCAmelCase							( self					:						Union[str, Any])   ->       Union[str, Any]:
         import torch

         lowercase_     			=   torch.tensor([1.0])
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         lowercase_     			=   torch.tensor([2.0])
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         lowercase_     			=   torch.tensor([1.0])
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertNotEqual(__lowerCAmelCase ,		__lowerCAmelCase)


   @require_spacy
   @require_spacy_model("en_core_web_sm")
   @require_spacy_model("fr_core_news_sm")
   @pytest.mark.integration
   def __UpperCAmelCase							( self					:						str)   ->       Dict:
         import spacy

         lowercase_     			=   spacy.load("en_core_web_sm")
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         lowercase_     			=   spacy.load("fr_core_news_sm")
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         lowercase_     			=   spacy.load("en_core_web_sm")
         lowercase_     			=   mda(datasets.utils.py_utils.dumps(__lowerCAmelCase)).hexdigest()
         self.assertEqual(__lowerCAmelCase ,		__lowerCAmelCase)
         self.assertNotEqual(__lowerCAmelCase ,		__lowerCAmelCase)




@pytest.mark.integration
def __a			(						__lowerCamelCase      :    Path					)						->				Union[str, Any]:
      '''simple docstring'''


      lowercase_     			=   tmp_path / "dir1"
      lowercase_     			=   tmp_path / "dir2"
      dira.mkdir()
      dira.mkdir()
      lowercase_     			=   "script.py"
      lowercase_     			=   dedent(
          "\n    from datasets.fingerprint import Hasher\n    def foo():\n        pass\n    print(Hasher.hash(foo))\n    "					)
      lowercase_     			=   dira / script_filename
      lowercase_     			=   dira / script_filename
      with script_patha.open("w"					) as f:
            f.write(__lowerCamelCase					)
      with script_patha.open("w"					) as f:
            f.write(__lowerCamelCase					)
      lowercase_     			=   subprocess.check_output(["python", str(__lowerCamelCase					)]					)
      lowercase_     			=   subprocess.check_output(["python", str(__lowerCamelCase					)]					)
      assert fingerprinta == fingerprinta


def __a			(						)						->				int:
      '''simple docstring'''


      lowercase_     			=   {"a": [0, 1, 2]}
      lowercase_     			=   DatasetChild(InMemoryTable.from_pydict(__lowerCamelCase					)					)
      lowercase_     			=   dataset.funca()._fingerprint
      assert expected_fingerprint == dataset.funca()._fingerprint
      assert expected_fingerprint != dataset.funca()._fingerprint

      with Pool(2					) as p:
            assert expected_fingerprint == p.apply_async(dataset.funca					).get()._fingerprint
            assert expected_fingerprint != p.apply_async(dataset.funca					).get()._fingerprint


def __a			(						)						->				Dict:
      '''simple docstring'''


      lowercase_     			=   {"a": [0, 1, 2]}





      class 				lowercase    (    datasets.Dataset			):


         @fingerprint_transform(inplace=__lowerCAmelCase)
         def __UpperCAmelCase							( self					:						Any ,		__lowerCAmelCase					:						List[Any])   ->       str:
               return DummyDatasetChild(self.data ,		fingerprint=__lowerCAmelCase)




      lowercase_     			=   DummyDatasetChild(InMemoryTable.from_pydict(__lowerCamelCase					)					).func()





      class 				lowercase    (    datasets.Dataset			):


         @fingerprint_transform(inplace=__lowerCAmelCase ,		version="1.0.0")
         def __UpperCAmelCase							( self					:						Optional[int] ,		__lowerCAmelCase					:						Dict)   ->       List[Any]:
               return DummyDatasetChild(self.data ,		fingerprint=__lowerCAmelCase)




      lowercase_     			=   DummyDatasetChild(InMemoryTable.from_pydict(__lowerCamelCase					)					).func()





      class 				lowercase    (    datasets.Dataset			):


         @fingerprint_transform(inplace=__lowerCAmelCase ,		version="2.0.0")
         def __UpperCAmelCase							( self					:						List[Any] ,		__lowerCAmelCase					:						Tuple)   ->       List[str]:
               return DummyDatasetChild(self.data ,		fingerprint=__lowerCAmelCase)




      lowercase_     			=   DummyDatasetChild(InMemoryTable.from_pydict(__lowerCamelCase					)					).func()

      assert len({fingeprint_no_version, fingeprint_a, fingeprint_a}					) == 3






def __a			(						)						->				Optional[int]:
      '''simple docstring'''


      lowercase_     			=   Hasher()
      hasher.update(lambda __lowerCamelCase					: x					)







'''simple docstring'''

import unittest
from dataclasses import dataclass
from typing import Optional

from transformers.utils import ModelOutput





@dataclass
class 				lowercase    (    __lowerCamelCase			):
   lowerCamelCase_            =42
   lowerCamelCase_            =None
   lowerCamelCase_            =None





class 				lowercase    (    unittest.TestCase			):


   def __UpperCAmelCase							( self					:						Tuple)   ->       Dict:
         lowercase_     			=   ModelOutputTest(a=30)
         self.assertEqual(x.a ,		30)
         self.assertIsNone(x.b)
         self.assertIsNone(x.c)
         with self.assertRaises(__lowerCAmelCase):
               lowercase_     			=   x.d


   def __UpperCAmelCase							( self					:						List[str])   ->       Union[str, Any]:
         lowercase_     			=   ModelOutputTest(a=30 ,		b=10)
         self.assertEqual(x[0] ,		30)
         self.assertEqual(x[1] ,		10)
         self.assertEqual(x[:2] ,		(30, 10))
         self.assertEqual(x[:] ,		(30, 10))

         lowercase_     			=   ModelOutputTest(a=30 ,		c=10)
         self.assertEqual(x[0] ,		30)
         self.assertEqual(x[1] ,		10)
         self.assertEqual(x[:2] ,		(30, 10))
         self.assertEqual(x[:] ,		(30, 10))


   def __UpperCAmelCase							( self					:						Union[str, Any])   ->       List[str]:
         lowercase_     			=   ModelOutputTest(a=30 ,		b=10)
         self.assertEqual(x["a"] ,		30)
         self.assertEqual(x["b"] ,		10)
         with self.assertRaises(__lowerCAmelCase):
               lowercase_     			=   x["c"]

         lowercase_     			=   ModelOutputTest(a=30 ,		c=10)
         self.assertEqual(x["a"] ,		30)
         self.assertEqual(x["c"] ,		10)
         with self.assertRaises(__lowerCAmelCase):
               lowercase_     			=   x["b"]


   def __UpperCAmelCase							( self					:						List[str])   ->       List[str]:
         lowercase_     			=   ModelOutputTest(a=30)
         self.assertEqual(list(x.keys()) ,		["a"])
         self.assertEqual(list(x.values()) ,		[30])
         self.assertEqual(list(x.items()) ,		[("a", 30)])
         self.assertEqual(list(__lowerCAmelCase) ,		["a"])

         lowercase_     			=   ModelOutputTest(a=30 ,		b=10)
         self.assertEqual(list(x.keys()) ,		["a", "b"])
         self.assertEqual(list(x.values()) ,		[30, 10])
         self.assertEqual(list(x.items()) ,		[("a", 30), ("b", 10)])
         self.assertEqual(list(__lowerCAmelCase) ,		["a", "b"])

         lowercase_     			=   ModelOutputTest(a=30 ,		c=10)
         self.assertEqual(list(x.keys()) ,		["a", "c"])
         self.assertEqual(list(x.values()) ,		[30, 10])
         self.assertEqual(list(x.items()) ,		[("a", 30), ("c", 10)])
         self.assertEqual(list(__lowerCAmelCase) ,		["a", "c"])

         with self.assertRaises(__lowerCAmelCase):
               lowercase_     			=   x.update({"d": 20})
         with self.assertRaises(__lowerCAmelCase):
               del x["a"]
         with self.assertRaises(__lowerCAmelCase):
               lowercase_     			=   x.pop("a")
         with self.assertRaises(__lowerCAmelCase):
               lowercase_     			=   x.setdefault("d" ,		32)


   def __UpperCAmelCase							( self					:						List[Any])   ->       Optional[int]:
         lowercase_     			=   ModelOutputTest(a=30)
         lowercase_     			=   10
         self.assertEqual(x.a ,		10)
         self.assertEqual(x["a"] ,		10)


   def __UpperCAmelCase							( self					:						List[Any])   ->       Any:
         lowercase_     			=   ModelOutputTest(a=30)
         lowercase_     			=   10
         self.assertEqual(x.a ,		10)
         self.assertEqual(x["a"] ,		10)


   def __UpperCAmelCase							( self					:						Union[str, Any])   ->       List[Any]:
         lowercase_     			=   ModelOutputTest({"a": 30, "b": 10})
         self.assertEqual(list(x.keys()) ,		["a", "b"])
         self.assertEqual(x.a ,		30)
         self.assertEqual(x.b ,		10)


   def __UpperCAmelCase							( self					:						List[str])   ->       str:
         lowercase_     			=   ModelOutputTest([("a", 30), ("b", 10)])
         self.assertEqual(list(x.keys()) ,		["a", "b"])
         self.assertEqual(x.a ,		30)
         self.assertEqual(x.b ,		10)

         with self.assertRaises(__lowerCAmelCase):
               lowercase_     			=   ModelOutputTest([("a", 30), (10, 10)])

         lowercase_     			=   ModelOutputTest(a=(30, 30))
         self.assertEqual(list(x.keys()) ,		["a"])
         self.assertEqual(x.a ,		(30, 30))






