





import argparse

import torch

from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel
from transformers.utils import logging


logging.set_verbosity_info()




def     __UpperCamelCase						(_SCREAMING_SNAKE_CASE	,		_SCREAMING_SNAKE_CASE	,		_SCREAMING_SNAKE_CASE	,		_SCREAMING_SNAKE_CASE	)       ->     str:
  # Initialise PyTorch model
  lowercase__			    =						FunnelConfig.from_json_file(_SCREAMING_SNAKE_CASE	)
  print(F"""Building PyTorch model from configuration: {config}"""	)
  lowercase__			    =						FunnelBaseModel(_SCREAMING_SNAKE_CASE	) if base_model else FunnelModel(_SCREAMING_SNAKE_CASE	)

  # Load weights from tf checkpoint
  load_tf_weights_in_funnel(_SCREAMING_SNAKE_CASE	,		_SCREAMING_SNAKE_CASE	,		_SCREAMING_SNAKE_CASE	)

  # Save pytorch-model
  print(F"""Save PyTorch model to {pytorch_dump_path}"""	)
  torch.save(model.state_dict()	,		_SCREAMING_SNAKE_CASE	)


if __name__ == "__main__":
      lowercase_					     =	argparse.ArgumentParser()
      # Required parameters
      parser.add_argument(
          """--tf_checkpoint_path""", default=None, type=str, required=True, help="""Path to the TensorFlow checkpoint path."""
      )
      parser.add_argument(
          """--config_file""",
          default=None,
          type=str,
          required=True,
          help="""The config json file corresponding to the pre-trained model. \nThis specifies the model architecture.""",
      )
      parser.add_argument(
          """--pytorch_dump_path""", default=None, type=str, required=True, help="""Path to the output PyTorch model."""
      )
      parser.add_argument(
          """--base_model""", action="""store_true""", help="""Whether you want just the base model (no decoder) or not."""
      )
      lowercase_					     =	parser.parse_args()
      convert_tf_checkpoint_to_pytorch(
          args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path, args.base_model
      )










from __future__ import annotations

import math
from collections.abc import Callable




def     __UpperCamelCase						(_SCREAMING_SNAKE_CASE	,		_SCREAMING_SNAKE_CASE	,		_SCREAMING_SNAKE_CASE	,		_SCREAMING_SNAKE_CASE = 100	,		)       ->     float:
  lowercase__			    =						x_start
  lowercase__			    =						fnc(_SCREAMING_SNAKE_CASE	)
  lowercase__			    =						0.0

  for _ in range(_SCREAMING_SNAKE_CASE	):
    # Approximates curve as a sequence of linear lines and sums their length
    lowercase__			    =						(x_end - x_start) / steps + xa
    lowercase__			    =						fnc(_SCREAMING_SNAKE_CASE	)
    length += math.hypot(xa - xa	,		fxa - fxa	)

    # Increment step
    lowercase__			    =						xa
    lowercase__			    =						fxa

  return length


if __name__ == "__main__":




      def     __UpperCamelCase						(_SCREAMING_SNAKE_CASE	)       ->     str:
        return math.sin(10 * x	)

      print("""f(x) = sin(10 * x)""")
      print("""The length of the curve from x = -10 to x = 10 is:""")
      lowercase_					     =	10
      while i <= 100_000:
            print(f'''With {i} steps: {line_length(f, -10, 10, i)}''')
            i *= 10


