
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 		__magic_name__				:


  """simple docstring"""





  def __init__(					self	,		a__		):
    _lowerCamelCase      =						foo


  def __call__(					self		):
    return self.foo







class 		__magic_name__				( datasets.Dataset					):


  """simple docstring"""





  @fingerprint_transform(inplace=__lowerCAmelCase		)
  def     _UpperCAmelCase  (					self	,		a__	,		*a__	,		**a__		):
    return DatasetChild(self.data	,		fingerprint=__lowerCAmelCase		)


  @fingerprint_transform(inplace=__lowerCAmelCase		)
  def     _UpperCAmelCase  (					self	,		a__	,		*a__	,		**a__		):
    return DatasetChild(self.data	,		fingerprint=__lowerCAmelCase		)







class 		__magic_name__				:


  """simple docstring"""





  def __init__(					self	,		a__		):
    _lowerCamelCase      =						callable


  def __call__(					self	,		*a__	,		**a__		):
    if self.callable is not None:
      return self.callable(*__lowerCAmelCase	,		**__lowerCAmelCase		)


  def __getstate__(					self		):
    raise pickle.PicklingError()







class 		__magic_name__				( __lowerCamelCase					):


  """simple docstring"""





  @require_transformers
  @pytest.mark.integration
  def     _UpperCAmelCase  (					self		):
    from transformers import AutoTokenizer

    def encode(a__		):
      return tokenizer(__lowerCAmelCase		)

    # TODO: add hash consistency tests across sessions
    _lowerCamelCase      =						AutoTokenizer.from_pretrained('''bert-base-uncased'''		)
    _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(__lowerCAmelCase		)		).hexdigest()
    _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(lambda a__		: tokenizer(__lowerCAmelCase		)		)		).hexdigest()
    _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(__lowerCAmelCase		)		).hexdigest()
    _lowerCamelCase      =						AutoTokenizer.from_pretrained('''bert-base-cased'''		)
    _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(__lowerCAmelCase		)		).hexdigest()
    _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(lambda a__		: tokenizer(__lowerCAmelCase		)		)		).hexdigest()
    _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(__lowerCAmelCase		)		).hexdigest()
    _lowerCamelCase      =						AutoTokenizer.from_pretrained('''bert-base-uncased'''		)
    _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(__lowerCAmelCase		)		).hexdigest()
    _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(lambda a__		: tokenizer(__lowerCAmelCase		)		)		).hexdigest()
    _lowerCamelCase      =						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		):
    from transformers import AutoTokenizer

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


  @require_regex
  def     _UpperCAmelCase  (					self		):
    import regex

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







class 		__magic_name__				( __lowerCamelCase					):


  """simple docstring"""





  def     _UpperCAmelCase  (					self		):
    def func():
      return foo

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


  def     _UpperCAmelCase  (					self		):
    def func():
      pass

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

    def func():
      pass

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


  def     _UpperCAmelCase  (					self		):
    _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(Foo([0]		)		)		).hexdigest()
    _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(Foo([1]		)		)		).hexdigest()
    _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(Foo([0]		)		)		).hexdigest()
    self.assertEqual(__lowerCAmelCase	,		__lowerCAmelCase		)
    self.assertNotEqual(__lowerCAmelCase	,		__lowerCAmelCase		)


  def     _UpperCAmelCase  (					self		):
    _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(Foo([0]		).__call__		)		).hexdigest()
    _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(Foo([1]		).__call__		)		).hexdigest()
    _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(Foo([0]		).__call__		)		).hexdigest()
    self.assertEqual(__lowerCAmelCase	,		__lowerCAmelCase		)
    self.assertNotEqual(__lowerCAmelCase	,		__lowerCAmelCase		)


  def     _UpperCAmelCase  (					self		):
    _lowerCamelCase      =						(
        '''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(*a__		):
      if hasattr(args[-3]	,		'''encode'''		):
        _lowerCamelCase      =						list(__lowerCAmelCase		)
        _lowerCamelCase      =						args[-3].encode()  # co_lnotab
        _lowerCamelCase      =						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(a__	,		a__		):
      def func():
        return returned_obj

      _lowerCamelCase      =						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'''		):
        _lowerCamelCase      =						_create_code_pyaa(
            *[getattr(__lowerCAmelCase	,		__lowerCAmelCase		) if k != '''co_filename''' else co_filename for k in code_args_pyaa]		)
      else:
        _lowerCamelCase      =						code.replace(co_filename=__lowerCAmelCase		)
      return FunctionType(__lowerCAmelCase	,		func.__globals__	,		func.__name__	,		func.__defaults__	,		func.__closure__		)

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

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


  def     _UpperCAmelCase  (					self		):
    _lowerCamelCase    ,    _lowerCamelCase      =						[0], [1]

    def func():
      return foo, bar

    _lowerCamelCase      =						'''__main__'''

    def globalvars_mocka_side_effect(a__	,		*a__	,		**a__		):
      return {"foo": foo, "bar": bar}

    def globalvars_mocka_side_effect(a__	,		*a__	,		**a__		):
      return {"bar": bar, "foo": foo}

    with patch('''dill.detect.globalvars'''	,		side_effect=__lowerCAmelCase		) as globalvars_mocka:
      _lowerCamelCase      =						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:
      _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(__lowerCAmelCase		)		).hexdigest()
      self.assertGreater(globalvars_mocka.call_count	,		0		)
    self.assertEqual(__lowerCAmelCase	,		__lowerCAmelCase		)







class 		__magic_name__				( __lowerCamelCase					):


  """simple docstring"""





  def     _UpperCAmelCase  (					self		):
    _lowerCamelCase      =						Hasher.hash('''hello'''		)
    _lowerCamelCase      =						Hasher.hash('''hello'''		)
    _lowerCamelCase      =						Hasher.hash('''there'''		)
    self.assertEqual(__lowerCAmelCase	,		__lowerCAmelCase		)
    self.assertNotEqual(__lowerCAmelCase	,		__lowerCAmelCase		)


  def     _UpperCAmelCase  (					self		):
    _lowerCamelCase      =						Hasher.hash(Foo('''hello'''		)		)
    _lowerCamelCase      =						Hasher.hash(Foo('''hello'''		)		)
    _lowerCamelCase      =						Hasher.hash(Foo('''there'''		)		)
    self.assertEqual(__lowerCAmelCase	,		__lowerCAmelCase		)
    self.assertNotEqual(__lowerCAmelCase	,		__lowerCAmelCase		)


  def     _UpperCAmelCase  (					self		):
    _lowerCamelCase      =						Hasher()
    for x in ["hello", Foo('''hello'''		)]:
      hasher.update(__lowerCAmelCase		)
    _lowerCamelCase      =						hasher.hexdigest()
    _lowerCamelCase      =						Hasher()
    for x in ["hello", Foo('''hello'''		)]:
      hasher.update(__lowerCAmelCase		)
    _lowerCamelCase      =						hasher.hexdigest()
    _lowerCamelCase      =						Hasher()
    for x in ["there", Foo('''there'''		)]:
      hasher.update(__lowerCAmelCase		)
    _lowerCamelCase      =						hasher.hexdigest()
    self.assertEqual(__lowerCAmelCase	,		__lowerCAmelCase		)
    self.assertNotEqual(__lowerCAmelCase	,		__lowerCAmelCase		)


  def     _UpperCAmelCase  (					self		):
    with self.assertRaises(pickle.PicklingError		):
      Hasher.hash(UnpicklableCallable(Foo('''hello'''		)		)		)


  def     _UpperCAmelCase  (					self		):
    _lowerCamelCase      =						'''abc'''
    _lowerCamelCase      =						[string, string]  # two strings have the same ids
    _lowerCamelCase      =						[string, string]
    _lowerCamelCase      =						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]		)
    _lowerCamelCase      =						Hasher.hash(__lowerCAmelCase		)
    _lowerCamelCase      =						Hasher.hash(__lowerCAmelCase		)
    _lowerCamelCase      =						Hasher.hash(__lowerCAmelCase		)
    self.assertEqual(__lowerCAmelCase	,		__lowerCAmelCase		)
    self.assertEqual(__lowerCAmelCase	,		__lowerCAmelCase		)


  @require_tiktoken
  def     _UpperCAmelCase  (					self		):
    import tiktoken

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


  @require_torch
  def     _UpperCAmelCase  (					self		):
    import torch

    _lowerCamelCase      =						torch.tensor([1.0]		)
    _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(__lowerCAmelCase		)		).hexdigest()
    _lowerCamelCase      =						torch.tensor([2.0]		)
    _lowerCamelCase      =						mda(datasets.utils.py_utils.dumps(__lowerCAmelCase		)		).hexdigest()
    _lowerCamelCase      =						torch.tensor([1.0]		)
    _lowerCamelCase      =						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		):
    import spacy

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







@pytest.mark.integration
def 		_lowerCamelCase       (   _a  ):
  """simple docstring"""




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


def 		_lowerCamelCase       (   ):
  """simple docstring"""




  _lowerCamelCase      =						{'''a''': [0, 1, 2]}
  _lowerCamelCase      =						DatasetChild(InMemoryTable.from_pydict(__lowerCamelCase  )  )
  _lowerCamelCase      =						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 		_lowerCamelCase       (   ):
  """simple docstring"""




  _lowerCamelCase      =						{'''a''': [0, 1, 2]}

  class 		__magic_name__				( datasets.Dataset					):


    """simple docstring"""





    @fingerprint_transform(inplace=__lowerCAmelCase		)
    def     _UpperCAmelCase  (					self	,		a__		):
      return DummyDatasetChild(self.data	,		fingerprint=__lowerCAmelCase		)







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

  class 		__magic_name__				( datasets.Dataset					):


    """simple docstring"""





    @fingerprint_transform(inplace=__lowerCAmelCase	,		version='''1.0.0'''		)
    def     _UpperCAmelCase  (					self	,		a__		):
      return DummyDatasetChild(self.data	,		fingerprint=__lowerCAmelCase		)







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

  class 		__magic_name__				( datasets.Dataset					):


    """simple docstring"""





    @fingerprint_transform(inplace=__lowerCAmelCase	,		version='''2.0.0'''		)
    def     _UpperCAmelCase  (					self	,		a__		):
      return DummyDatasetChild(self.data	,		fingerprint=__lowerCAmelCase		)







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

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






def 		_lowerCamelCase       (   ):
  """simple docstring"""




  _lowerCamelCase      =						Hasher()
  hasher.update(lambda _a  : x  )





'''simple docstring'''

from hashlib import mda, shaaaa

lowerCAmelCase_			:			Union[str, Any]    	=   (shaaaa, mda)





class 				lowercase    :


   def __init__( self					:						Optional[Any] ,		__lowerCAmelCase					:						int = 8)   ->       None:
         lowercase_     			=   0B0
         lowercase_     			=   size


   def __UpperCAmelCase							( self					:						Dict ,		__lowerCAmelCase					:						str)   ->       None:
         lowercase_     			=   self.hash_(__lowerCAmelCase)
         self.bitarray |= h


   def __UpperCAmelCase							( self					:						Union[str, Any] ,		__lowerCAmelCase					:						str)   ->       bool:
         lowercase_     			=   self.hash_(__lowerCAmelCase)
         return (h & self.bitarray) == h


   def __contains__( self					:						str ,		__lowerCAmelCase					:						str)   ->       bool:
         return self.exists(__lowerCAmelCase)


   def __UpperCAmelCase							( self					:						Union[str, Any] ,		__lowerCAmelCase					:						int)   ->       str:
         lowercase_     			=   bin(__lowerCAmelCase)[2:]
         return res.zfill(self.size)


   @property
   def __UpperCAmelCase							( self					:						Dict)   ->       str:
         return self.format_bin(self.bitarray)


   def __UpperCAmelCase							( self					:						Any ,		__lowerCAmelCase					:						str)   ->       int:
         lowercase_     			=   0B0
         for func in HASH_FUNCTIONS:
               lowercase_     			=   (
                   int.from_bytes(func(value.encode()).digest() ,		"little") % self.size
               )
               res |= 2**position
         return res


   def __UpperCAmelCase							( self					:						Union[str, Any] ,		__lowerCAmelCase					:						str)   ->       str:
         return self.format_bin(self.hash_(__lowerCAmelCase))


   @property
   def __UpperCAmelCase							( self					:						str)   ->       float:
         lowercase_     			=   bin(self.bitarray).count("1")
         return (n_ones / self.size) ** len(__lowerCAmelCase)






