






'''simple docstring'''







from typing import Optional, Union

from ...file_utils import TensorType
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, TruncationStrategy






class 					a__    (			lowerCamelCase						):
     '''simple docstring'''







     _snake_case             =  'MarkupLMFeatureExtractor'
     _snake_case             =  ('MarkupLMTokenizer', 'MarkupLMTokenizerFast')
     _snake_case             =  True






     def __call__(self    :	Optional[Any]				,				lowercase__    :	List[Any]=None				,				lowercase__    :	Union[str, Any]=None				,				lowercase__    :	int=None				,				lowercase__    :	Union[str, Any]=None				,				lowercase__    :	str=None				,				lowercase__    :	bool = True				,				lowercase__    :	Union[bool, str, PaddingStrategy] = False				,				lowercase__    :	Union[bool, str, TruncationStrategy] = None				,				lowercase__    :	Optional[int] = None				,				lowercase__    :	int = 0				,				lowercase__    :	Optional[int] = None				,				lowercase__    :	Optional[bool] = None				,				lowercase__    :	Optional[bool] = None				,				lowercase__    :	bool = False				,				lowercase__    :	bool = False				,				lowercase__    :	bool = False				,				lowercase__    :	bool = False				,				lowercase__    :	bool = True				,				lowercase__    :	Optional[Union[str, TensorType]] = None				,				**lowercase__    :	List[Any]				,				)  ->       int:
           # first, create nodes and xpaths
           if self.parse_html:
                 if html_strings is None:
                       raise ValueError("Make sure to pass HTML strings in case `parse_html` is set to `True`"					)

                 if nodes is not None or xpaths is not None or node_labels is not None:
                       raise ValueError(
                           "Please don't pass nodes, xpaths nor node labels in case `parse_html` is set to `True`"					)

                 __A		   =      self.feature_extractor(A_					)
                 __A		   =      features["nodes"]
                 __A		   =      features["xpaths"]
           else:
                 if html_strings is not None:
                       raise ValueError("You have passed HTML strings but `parse_html` is set to `False`."					)
                 if nodes is None or xpaths is None:
                       raise ValueError("Make sure to pass nodes and xpaths in case `parse_html` is set to `False`"					)

        # # second, apply the tokenizer
           if questions is not None and self.parse_html:
                 if isinstance(A_				,				A_					):
                       __A		   =      [questions]  # add batch dimension (as the feature extractor always adds a batch dimension)

           __A		   =      self.tokenizer(
               text=questions if questions is not None else nodes				,				text_pair=nodes if questions is not None else None				,				xpaths=A_				,				node_labels=A_				,				add_special_tokens=A_				,				padding=A_				,				truncation=A_				,				max_length=A_				,				stride=A_				,				pad_to_multiple_of=A_				,				return_token_type_ids=A_				,				return_attention_mask=A_				,				return_overflowing_tokens=A_				,				return_special_tokens_mask=A_				,				return_offsets_mapping=A_				,				return_length=A_				,				verbose=A_				,				return_tensors=A_				,				**A_				,				)

           return encoded_inputs






     def     _UpperCamelCase   (self    :	int				,				*lowercase__    :	str				,				**lowercase__    :	Union[str, Any]					)  ->       Tuple:
           return self.tokenizer.batch_decode(*A_				,				**A_					)






     def     _UpperCamelCase   (self    :	Any				,				*lowercase__    :	Optional[int]				,				**lowercase__    :	Any					)  ->       Optional[Any]:
           return self.tokenizer.decode(*A_				,				**A_					)






     @property
     def     _UpperCamelCase   (self    :	int					)  ->       Any:
           __A		   =      self.tokenizer.model_input_names
           return tokenizer_input_names









'''simple docstring'''







import importlib
import sys
from argparse import REMAINDER, ArgumentParser
from pathlib import Path

import torch_xla.distributed.xla_multiprocessing as xmp


def 						_UpperCamelCase							(     ):
      __A		   =      ArgumentParser(
          description=(
              "PyTorch TPU distributed training launch helper utility that will spawn up multiple distributed processes"
          )							)

      # Optional arguments for the launch helper
      parser.add_argument("--num_cores"							,			type=snake_case__							,			default=1							,			help="Number of TPU cores to use (1 or 8)."							)

      # positional
      parser.add_argument(
          "training_script"							,			type=snake_case__							,			help=(
              "The full path to the single TPU training "
              "program/script to be launched in parallel, "
              "followed by all the arguments for the "
              "training script"
          )							,			)

      # rest from the training program
      parser.add_argument("training_script_args"							,			nargs=snake_case__							)

      return parser.parse_args()


def 						_UpperCamelCase							(     ):
      __A		   =      parse_args()

      # Import training_script as a module.
      __A		   =      Path(args.training_script							)
      sys.path.append(str(script_fpath.parent.resolve()							)							)
      __A		   =      script_fpath.stem
      __A		   =      importlib.import_module(snake_case__							)

      # Patch sys.argv
      __A		   =      [args.training_script] + args.training_script_args + ["--tpu_num_cores", str(args.num_cores							)]

      xmp.spawn(mod._mp_fn							,			args=()							,			nprocs=args.num_cores							)


if __name__ == "__main__":
       main()


