




'''simple docstring'''
import importlib
import inspect
from functools import wraps
from typing import TYPE_CHECKING, Optional, Union

from .download.streaming_download_manager import (
    xbasename,
    xdirname,
    xet_parse,
    xexists,
    xgetsize,
    xglob,
    xgzip_open,
    xisdir,
    xisfile,
    xjoin,
    xlistdir,
    xnumpy_load,
    xopen,
    xpandas_read_csv,
    xpandas_read_excel,
    xPath,
    xrelpath,
    xsio_loadmat,
    xsplit,
    xsplitext,
    xwalk,
    xxml_dom_minidom_parse,
)
from .utils.logging import get_logger
from .utils.patching import patch_submodule
from .utils.py_utils import get_imports


A							:      Union[str, Any] 	=       get_logger(__name__)


if TYPE_CHECKING:
  from .builder import DatasetBuilder
def 				snake_case_  (   a__		:	Optional[int]    ,a__		:	List[str] = None			):



    """simple docstring"""




    __lowercase							=						importlib.import_module(__UpperCAmelCase			)

    # TODO(QL): always update the module to add subsequent new authentication
    if hasattr(__UpperCAmelCase    ,"""_patched_for_streaming"""			) and module._patched_for_streaming:
        return

    def wrap_auth(a__		:	List[Any]			):
        @wraps(__UpperCAmelCase			)
        def wrapper(*a__		:	List[Any]    ,**a__		:	Optional[int]			):
            return function(*__UpperCAmelCase    ,use_auth_token=__UpperCAmelCase    ,**__UpperCAmelCase			)

        __lowercase							=						"""wrap_auth"""
        return wrapper

    # open files in a streaming fashion
    patch_submodule(__UpperCAmelCase    ,"""open"""    ,wrap_auth(__UpperCAmelCase			)			).start()
    patch_submodule(__UpperCAmelCase    ,"""os.listdir"""    ,wrap_auth(__UpperCAmelCase			)			).start()
    patch_submodule(__UpperCAmelCase    ,"""os.walk"""    ,wrap_auth(__UpperCAmelCase			)			).start()
    patch_submodule(__UpperCAmelCase    ,"""glob.glob"""    ,wrap_auth(__UpperCAmelCase			)			).start()
    # allow to navigate in remote zip files
    patch_submodule(__UpperCAmelCase    ,"""os.path.join"""    ,__UpperCAmelCase			).start()
    patch_submodule(__UpperCAmelCase    ,"""os.path.dirname"""    ,__UpperCAmelCase			).start()
    patch_submodule(__UpperCAmelCase    ,"""os.path.basename"""    ,__UpperCAmelCase			).start()
    patch_submodule(__UpperCAmelCase    ,"""os.path.relpath"""    ,__UpperCAmelCase			).start()
    patch_submodule(__UpperCAmelCase    ,"""os.path.split"""    ,__UpperCAmelCase			).start()
    patch_submodule(__UpperCAmelCase    ,"""os.path.splitext"""    ,__UpperCAmelCase			).start()
    # allow checks on paths
    patch_submodule(__UpperCAmelCase    ,"""os.path.exists"""    ,wrap_auth(__UpperCAmelCase			)			).start()
    patch_submodule(__UpperCAmelCase    ,"""os.path.isdir"""    ,wrap_auth(__UpperCAmelCase			)			).start()
    patch_submodule(__UpperCAmelCase    ,"""os.path.isfile"""    ,wrap_auth(__UpperCAmelCase			)			).start()
    patch_submodule(__UpperCAmelCase    ,"""os.path.getsize"""    ,wrap_auth(__UpperCAmelCase			)			).start()
    patch_submodule(__UpperCAmelCase    ,"""pathlib.Path"""    ,__UpperCAmelCase			).start()
    # file readers
    patch_submodule(__UpperCAmelCase    ,"""gzip.open"""    ,wrap_auth(__UpperCAmelCase			)			).start()
    patch_submodule(__UpperCAmelCase    ,"""numpy.load"""    ,wrap_auth(__UpperCAmelCase			)			).start()
    patch_submodule(__UpperCAmelCase    ,"""pandas.read_csv"""    ,wrap_auth(__UpperCAmelCase			)    ,attrs=["""__version__"""]			).start()
    patch_submodule(__UpperCAmelCase    ,"""pandas.read_excel"""    ,wrap_auth(__UpperCAmelCase			)    ,attrs=["""__version__"""]			).start()
    patch_submodule(__UpperCAmelCase    ,"""scipy.io.loadmat"""    ,wrap_auth(__UpperCAmelCase			)    ,attrs=["""__version__"""]			).start()
    patch_submodule(__UpperCAmelCase    ,"""xml.etree.ElementTree.parse"""    ,wrap_auth(__UpperCAmelCase			)			).start()
    patch_submodule(__UpperCAmelCase    ,"""xml.dom.minidom.parse"""    ,wrap_auth(__UpperCAmelCase			)			).start()
    __lowercase							=						True



def 				snake_case_  (   a__		:	List[Any]			):



    """simple docstring"""




    extend_module_for_streaming(builder.__module__    ,use_auth_token=builder.use_auth_token			)
    # if needed, we also have to extend additional internal imports (like wmt14 -> wmt_utils)
    if not builder.__module__.startswith("""datasets."""			):  # check that it's not a packaged builder like csv
        for imports in get_imports(inspect.getfile(builder.__class__			)			):
            if imports[0] == "internal":
                __lowercase							=						imports[1]
                __lowercase							=						""".""".join(builder.__module__.split("""."""			)[:-1] + [internal_import_name]			)
                extend_module_for_streaming(__UpperCAmelCase    ,use_auth_token=builder.use_auth_token			)

    # builders can inherit from other builders that might use streaming functionality
    # (for example, ImageFolder and AudioFolder inherit from FolderBuilder which implements examples generation)
    # but these parents builders are not patched automatically as they are not instantiated, so we patch them here
    from .builder import DatasetBuilder

    __lowercase							=						[
        cls.__module__
        for cls in type(__UpperCAmelCase			).__mro__[1:]  # make sure it's not the same module we've already patched
        if issubclass(cls    ,__UpperCAmelCase			) and cls.__module__ != DatasetBuilder.__module__
    ]  # check it's not a standard builder from datasets.builder
    for module in parent_builder_modules:
        extend_module_for_streaming(__UpperCAmelCase    ,use_auth_token=builder.use_auth_token			)









from __future__ import annotations

from pathlib import Path







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase	)       ->       int:



						'''simple docstring'''






						return pointa[0] * pointa[1] - pointa[1] * pointa[0]







def 				A			(		__UpperCAmelCase							,					__UpperCAmelCase							,					__UpperCAmelCase							,					__UpperCAmelCase							,					__UpperCAmelCase							,					__UpperCAmelCase	)       ->       bool:



						'''simple docstring'''






						UpperCAmelCase_     							=     (xa, ya)
						UpperCAmelCase_     							=     (xa - xa, ya - ya)
						UpperCAmelCase_     							=     (xa - xa, ya - ya)
						UpperCAmelCase_     							=     -vector_product(__UpperCAmelCase							,					__UpperCAmelCase	) / vector_product(
						    __UpperCAmelCase							,					__UpperCAmelCase	)
						UpperCAmelCase_     							=     +vector_product(__UpperCAmelCase							,					__UpperCAmelCase	) / vector_product(
						    __UpperCAmelCase							,					__UpperCAmelCase	)

						return a > 0 and b > 0 and a + b < 1







def 				A			(		__UpperCAmelCase = "p102_triangles.txt"	)       ->       int:



						'''simple docstring'''






						UpperCAmelCase_     							=     Path(__UpperCAmelCase	).parent.joinpath(__UpperCAmelCase	).read_text(encoding='''utf-8'''	)

						UpperCAmelCase_     							=     []
						for line in data.strip().split('''\n'''	):
												triangles.append([int(__UpperCAmelCase	) for number in line.split(''','''	)]	)

						UpperCAmelCase_     							=     0
						UpperCAmelCase_     							=     42

						for triangle in triangles:
												ret += contains_origin(*__UpperCAmelCase	)

						return ret


if __name__ == "__main__":
							print(f"{solution() = }")





