


def   A   (		A__		,		A__ ):
     # The longer word should come first
     if len(lowerCAmelCase__ ) < len(lowerCAmelCase__ ):
          return levenshtein_distance(lowerCAmelCase__		,		lowerCAmelCase__ )

     if len(lowerCAmelCase__ ) == 0:
          return len(lowerCAmelCase__ )

     UpperCAmelCase						:				Optional[int]		  =			list(range(len(lowerCAmelCase__ ) + 1 ) )

     for i, ca in enumerate(lowerCAmelCase__ ):
          UpperCAmelCase						:				Union[str, Any]		  =			[i + 1]

          for j, ca in enumerate(lowerCAmelCase__ ):
               # Calculate insertions, deletions and substitutions
               UpperCAmelCase						:				Any		  =			previous_row[j + 1] + 1
               UpperCAmelCase						:				List[Any]		  =			current_row[j] + 1
               UpperCAmelCase						:				Dict		  =			previous_row[j] + (ca != ca)

               # Get the minimum to append to the current row
               current_row.append(min(lowerCAmelCase__		,		lowerCAmelCase__		,		lowerCAmelCase__ ) )

          # Store the previous row
          UpperCAmelCase						:				Optional[int]		  =			current_row

     # Returns the last element (distance)
     return previous_row[-1]


if __name__ == "__main__":
      _SCREAMING_SNAKE_CASE   = input("Enter the first word:\n").strip()
      _SCREAMING_SNAKE_CASE   = input("Enter the second word:\n").strip()

      _SCREAMING_SNAKE_CASE   = levenshtein_distance(first_word, second_word)
      print(f'''Levenshtein distance between {first_word} and {second_word} is {result}''')







import json
import os
import tempfile

import datasets
from datasets.arrow_writer import ArrowWriter
from datasets.features import ArrayaD
from utils import generate_examples, get_duration


_snake_case   = (3_0, 4_8_7)
_snake_case   = (3_6, 1_0_2_4)
_snake_case   = (1_0_0, 1_0_0)
_snake_case   = 1_0_0

_snake_case   = datasets.Features(
    {"text": ArrayaD(SHAPE_TEST_1, dtype="float32"), "image": ArrayaD(SHAPE_TEST_2, dtype="float32")}
)

_snake_case ,						_snake_case   = os.path.split(__file__)
_snake_case   = os.path.join(RESULTS_BASEPATH, "results", RESULTS_FILENAME.replace(".py", ".json"))







@get_duration
def   A   (		A__		,		A__		,		A__ ):
     with ArrowWriter(features=A__		,		path=os.path.join(A__		,		"beta.arrow" ) ) as writer:
          for key, record in dummy_data:
               UpperCAmelCase						:				Union[str, Any]		  =			my_features.encode_example(A__ )
               writer.write(A__ )
          UpperCAmelCase  , UpperCAmelCase						:				List[str]		  =			writer.finalize()







@get_duration
def   A   (		A__		,		A__ ):
     UpperCAmelCase						:				List[Any]		  =			datasets.Dataset.from_file(
         filename=os.path.join(A__		,		"beta.arrow" )		,		info=datasets.DatasetInfo(features=A__ ) )
     for _ in dataset:
          pass







@get_duration
def   A   (		A__		,		A__ ):
     UpperCAmelCase						:				Tuple		  =			datasets.Dataset.from_file(
         filename=os.path.join(A__		,		"beta.arrow" )		,		info=datasets.DatasetInfo(features=A__ ) )
     dataset.set_format("numpy" )
     for _ in dataset:
          pass







@get_duration
def   A   (		A__		,		A__ ):
     UpperCAmelCase						:				Union[str, Any]		  =			1_0
     UpperCAmelCase						:				str		  =			datasets.Dataset.from_file(
         filename=os.path.join(A__		,		"beta.arrow" )		,		info=datasets.DatasetInfo(features=A__ ) )
     for i in range(0		,		len(A__ )		,		A__ ):
          UpperCAmelCase						:				Dict		  =			dataset[i : i + batch_size]







@get_duration
def   A   (		A__		,		A__ ):
     UpperCAmelCase						:				Any		  =			1_0
     UpperCAmelCase						:				List[str]		  =			datasets.Dataset.from_file(
         filename=os.path.join(A__		,		"beta.arrow" )		,		info=datasets.DatasetInfo(features=A__ ) )
     dataset.set_format("numpy" )
     for i in range(0		,		len(A__ )		,		A__ ):
          UpperCAmelCase						:				List[str]		  =			dataset[i : i + batch_size]







@get_duration
def   A   (		A__		,		A__ ):
     UpperCAmelCase						:				Tuple		  =			datasets.Dataset.from_file(
         filename=os.path.join(A__		,		"beta.arrow" )		,		info=datasets.DatasetInfo(features=A__ ) )
     for col in feats:
          UpperCAmelCase						:				Any		  =			dataset[col]







@get_duration
def   A   (		A__		,		A__ ):
     UpperCAmelCase						:				Union[str, Any]		  =			datasets.Dataset.from_file(
         filename=os.path.join(A__		,		"beta.arrow" )		,		info=datasets.DatasetInfo(features=A__ ) )
     dataset.set_format("numpy" )
     for col in feats:
          UpperCAmelCase						:				str		  =			dataset[col]







def   A   (		):
     UpperCAmelCase						:				Tuple		  =			{}
     UpperCAmelCase						:				int		  =			(
         read_unformated,
         read_formatted_as_numpy,
         read_batch_unformated,
         read_batch_formatted_as_numpy,
         read_col_unformated,
         read_col_formatted_as_numpy,
     )
     with tempfile.TemporaryDirectory() as tmp_dir:
          UpperCAmelCase						:				Optional[Any]		  =			datasets.Features({"image": ArrayaD(A__		,		dtype="float32" )} )
          UpperCAmelCase						:				List[Any]		  =			generate_examples(features=A__		,		num_examples=A__ )
          UpperCAmelCase						:				Optional[Any]		  =			write(A__		,		A__		,		A__ )
          for read_func in read_functions:
               UpperCAmelCase						:				Optional[int]		  =			read_func(A__		,		A__ )

     with tempfile.TemporaryDirectory() as tmp_dir:
          # don't use fixed length for fair comparison
          # feats = datasets.Features(
          #     {"image": datasets.Sequence(datasets.Sequence(datasets.Value("float32"), SPEED_TEST_SHAPE[1]), SPEED_TEST_SHAPE[0])}
          # )
          UpperCAmelCase						:				Any		  =			datasets.Features({"image": datasets.Sequence(datasets.Sequence(datasets.Value("float32" ) ) )} )
          UpperCAmelCase						:				Optional[Any]		  =			generate_examples(
              features=A__		,		num_examples=A__		,		seq_shapes={"image": SPEED_TEST_SHAPE} )
          UpperCAmelCase						:				List[str]		  =			write(A__		,		A__		,		A__ )
          for read_func in read_functions:
               UpperCAmelCase						:				List[Any]		  =			read_func(A__		,		A__ )

     with tempfile.TemporaryDirectory() as tmp_dir:
          # don't use fixed length for fair comparison
          # feats = datasets.Features(
          #     {"image": datasets.Sequence(datasets.Value("float32"), SPEED_TEST_SHAPE[0] * SPEED_TEST_SHAPE[1])}
          # )
          UpperCAmelCase						:				Any		  =			datasets.Features({"image": datasets.Sequence(datasets.Value("float32" ) )} )
          UpperCAmelCase						:				Any		  =			generate_examples(
              features=A__		,		num_examples=A__		,		seq_shapes={"image": [SPEED_TEST_SHAPE[0] * SPEED_TEST_SHAPE[1]]}		,		)
          UpperCAmelCase						:				Optional[int]		  =			write(A__		,		A__		,		A__ )
          for read_func in read_functions:
               UpperCAmelCase						:				Optional[Any]		  =			read_func(A__		,		A__ )

     with open(A__		,		"wb" ) as f:
          f.write(json.dumps(A__ ).encode("utf-8" ) )


if __name__ == "__main__":  # useful to run the profiler
      benchmark_array_xd()



