import inspect
import tempfile
from collections import OrderedDict, UserDict
from collections.abc import MutableMapping
from contextlib import ExitStack, contextmanager
from dataclasses import fields
from enum import Enum
from typing import Any, ContextManager, List, Tuple

import numpy as np

from .import_utils import is_flax_available, is_tf_available, is_torch_available, is_torch_fx_proxy


if is_flax_available():
   import jax.numpy as jnp







class __snake_case    (						lowerCamelCase_		):




   def __get__(   self      :    Tuple	,     _lowercase      :    Union[str, Any]	,     _lowercase      :    Optional[int]=None				):



     """simple docstring"""






     if obj is None:
       return self
     if self.fget is None:
       raise AttributeError("""unreadable attribute"""				)
     SCREAMING_SNAKE_CASE__      							=				"""__cached_""" + self.fget.__name__
     SCREAMING_SNAKE_CASE__      							=				getattr(_lowercase	,     _lowercase	,     _lowercase				)
     if cached is None:
       SCREAMING_SNAKE_CASE__      							=				self.fget(_lowercase				)
       setattr(_lowercase	,     _lowercase	,     _lowercase				)
     return cached





def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	Union[str, Any]     )							-> Union[str, Any]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__      							=				val.lower()
  if val in {"y", "yes", "t", "true", "on", "1"}:
    return 1
  if val in {"n", "no", "f", "false", "off", "0"}:
    return 0
  raise ValueError(f"""invalid truth value {val!r}"""     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	int     )							-> Any:







  """simple docstring"""





  if is_torch_fx_proxy(__UpperCamelCase     ):
    return True
  if is_torch_available():
    import torch

    if isinstance(__UpperCamelCase			,					torch.Tensor     ):
      return True
  if is_tf_available():
    import tensorflow as tf

    if isinstance(__UpperCamelCase			,					tf.Tensor     ):
      return True

  if is_flax_available():
    import jax.numpy as jnp
    from jax.core import Tracer

    if isinstance(__UpperCamelCase			,					(jnp.ndarray, Tracer)     ):
      return True

  return isinstance(__UpperCamelCase			,					np.ndarray     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	Dict     )							-> int:







  """simple docstring"""





  return isinstance(__UpperCamelCase			,					np.ndarray     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	List[str]     )							-> Optional[int]:







  """simple docstring"""





  return _is_numpy(__UpperCamelCase     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	Tuple     )							-> Union[str, Any]:







  """simple docstring"""





  import torch

  return isinstance(__UpperCamelCase			,					torch.Tensor     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	int     )							-> List[Any]:







  """simple docstring"""





  return False if not is_torch_available() else _is_torch(__UpperCamelCase     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	Tuple     )							-> Union[str, Any]:







  """simple docstring"""





  import torch

  return isinstance(__UpperCamelCase			,					torch.device     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	Dict     )							-> Optional[Any]:







  """simple docstring"""





  return False if not is_torch_available() else _is_torch_device(__UpperCamelCase     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	Union[str, Any]     )							-> Union[str, Any]:







  """simple docstring"""





  import torch

  if isinstance(__UpperCamelCase			,					__UpperCamelCase     ):
    if hasattr(__UpperCamelCase			,					__UpperCamelCase     ):
      SCREAMING_SNAKE_CASE__      							=				getattr(__UpperCamelCase			,					__UpperCamelCase     )
    else:
      return False
  return isinstance(__UpperCamelCase			,					torch.dtype     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	Dict     )							-> Union[str, Any]:







  """simple docstring"""





  return False if not is_torch_available() else _is_torch_dtype(__UpperCamelCase     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	Any     )							-> Dict:







  """simple docstring"""





  import tensorflow as tf

  return isinstance(__UpperCamelCase			,					tf.Tensor     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	Union[str, Any]     )							-> int:







  """simple docstring"""





  return False if not is_tf_available() else _is_tensorflow(__UpperCamelCase     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	Any     )							-> int:







  """simple docstring"""





  import tensorflow as tf

  # the `is_symbolic_tensor` predicate is only available starting with TF 2.14
  if hasattr(__UpperCamelCase			,					"""is_symbolic_tensor"""     ):
    return tf.is_symbolic_tensor(__UpperCamelCase     )
  return type(__UpperCamelCase     ) == tf.Tensor



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	Tuple     )							-> Tuple:







  """simple docstring"""





  return False if not is_tf_available() else _is_tf_symbolic_tensor(__UpperCamelCase     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	Optional[Any]     )							-> Dict:







  """simple docstring"""





  import jax.numpy as jnp  # noqa: F811

  return isinstance(__UpperCamelCase			,					jnp.ndarray     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	str     )							-> List[Any]:







  """simple docstring"""





  return False if not is_flax_available() else _is_jax(__UpperCamelCase     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	List[str]     )							-> Optional[int]:







  """simple docstring"""





  if isinstance(__UpperCamelCase			,					(dict, UserDict)     ):
    return {k: to_py_obj(__UpperCamelCase     ) for k, v in obj.items()}
  elif isinstance(__UpperCamelCase			,					(list, tuple)     ):
    return [to_py_obj(__UpperCamelCase     ) for o in obj]
  elif is_tf_tensor(__UpperCamelCase     ):
    return obj.numpy().tolist()
  elif is_torch_tensor(__UpperCamelCase     ):
    return obj.detach().cpu().tolist()
  elif is_jax_tensor(__UpperCamelCase     ):
    return np.asarray(__UpperCamelCase     ).tolist()
  elif isinstance(__UpperCamelCase			,					(np.ndarray, np.number)     ):  # tolist also works on 0d np arrays
    return obj.tolist()
  else:
    return obj



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	str     )							-> Tuple:







  """simple docstring"""





  if isinstance(__UpperCamelCase			,					(dict, UserDict)     ):
    return {k: to_numpy(__UpperCamelCase     ) for k, v in obj.items()}
  elif isinstance(__UpperCamelCase			,					(list, tuple)     ):
    return np.array(__UpperCamelCase     )
  elif is_tf_tensor(__UpperCamelCase     ):
    return obj.numpy()
  elif is_torch_tensor(__UpperCamelCase     ):
    return obj.detach().cpu().numpy()
  elif is_jax_tensor(__UpperCamelCase     ):
    return np.asarray(__UpperCamelCase     )
  else:
    return obj







class __snake_case    (						lowerCamelCase_		):




   def      __a						(   self      :    int				):



     """simple docstring"""






     SCREAMING_SNAKE_CASE__      							=				fields(self				)

     # Safety and consistency checks
     if not len(_lowercase				):
       raise ValueError(f"""{self.__class__.__name__} has no fields."""				)
     if not all(field.default is None for field in class_fields[1:]				):
       raise ValueError(f"""{self.__class__.__name__} should not have more than one required field."""				)

     SCREAMING_SNAKE_CASE__      							=				getattr(self	,     class_fields[0].name				)
     SCREAMING_SNAKE_CASE__      							=				all(getattr(self	,     field.name				) is None for field in class_fields[1:]				)

     if other_fields_are_none and not is_tensor(_lowercase				):
       if isinstance(_lowercase	,     _lowercase				):
         SCREAMING_SNAKE_CASE__      							=				first_field.items()
         SCREAMING_SNAKE_CASE__      							=				True
       else:
         try:
           SCREAMING_SNAKE_CASE__      							=				iter(_lowercase				)
           SCREAMING_SNAKE_CASE__      							=				True
         except TypeError:
           SCREAMING_SNAKE_CASE__      							=				False

            # if we provided an iterator as first field and the iterator is a (key, value) iterator
            # set the associated fields
       if first_field_iterator:
         for idx, element in enumerate(_lowercase				):
           if (
               not isinstance(_lowercase	,     (list, tuple)				)
               or not len(_lowercase				) == 2
               or not isinstance(element[0]	,     _lowercase				)
           ):
             if idx == 0:
               # If we do not have an iterator of key/values, set it as attribute
               SCREAMING_SNAKE_CASE__      							=				first_field
             else:
               # If we have a mixed iterator, raise an error
               raise ValueError(
                   f"""Cannot set key/value for {element}. It needs to be a tuple (key, value)."""				)
             break
           setattr(self	,     element[0]	,     element[1]				)
           if element[1] is not None:
             SCREAMING_SNAKE_CASE__      							=				element[1]
       elif first_field is not None:
         SCREAMING_SNAKE_CASE__      							=				first_field
     else:
       for field in class_fields:
         SCREAMING_SNAKE_CASE__      							=				getattr(self	,     field.name				)
         if v is not None:
           SCREAMING_SNAKE_CASE__      							=				v




   def __delitem__(   self      :    Tuple	,     *_lowercase      :    Optional[Any]	,     **_lowercase      :    Optional[Any]				):



     """simple docstring"""






     raise Exception(f"""You cannot use ``__delitem__`` on a {self.__class__.__name__} instance."""				)




   def      __a						(   self      :    Optional[Any]	,     *_lowercase      :    List[str]	,     **_lowercase      :    Any				):



     """simple docstring"""






     raise Exception(f"""You cannot use ``setdefault`` on a {self.__class__.__name__} instance."""				)




   def      __a						(   self      :    Dict	,     *_lowercase      :    Dict	,     **_lowercase      :    List[str]				):



     """simple docstring"""






     raise Exception(f"""You cannot use ``pop`` on a {self.__class__.__name__} instance."""				)




   def      __a						(   self      :    int	,     *_lowercase      :    Any	,     **_lowercase      :    Any				):



     """simple docstring"""






     raise Exception(f"""You cannot use ``update`` on a {self.__class__.__name__} instance."""				)




   def __getitem__(   self      :    Union[str, Any]	,     _lowercase      :    Optional[int]				):



     """simple docstring"""






     if isinstance(_lowercase	,     _lowercase				):
       SCREAMING_SNAKE_CASE__      							=				dict(self.items()				)
       return inner_dict[k]
     else:
       return self.to_tuple()[k]




   def __setattr__(   self      :    Dict	,     _lowercase      :    str	,     _lowercase      :    Dict				):



     """simple docstring"""






     if name in self.keys() and value is not None:
       # Don't call self.__setitem__ to avoid recursion errors
       super().__setitem__(_lowercase	,     _lowercase				)
     super().__setattr__(_lowercase	,     _lowercase				)




   def __setitem__(   self      :    Optional[Any]	,     _lowercase      :    Optional[int]	,     _lowercase      :    List[str]				):



     """simple docstring"""






     super().__setitem__(_lowercase	,     _lowercase				)
     # Don't call self.__setattr__ to avoid recursion errors
     super().__setattr__(_lowercase	,     _lowercase				)




   def      __a						(   self      :    Optional[int]				):



     """simple docstring"""






     return tuple(self[k] for k in self.keys()				)







class __snake_case    (						lowerCamelCase_       ,		lowerCamelCase_		):




   @classmethod
   def      __a						(   cls      :    List[str]	,     _lowercase      :    Any				):



     """simple docstring"""






     raise ValueError(
         f"""{value} is not a valid {cls.__name__}, please select one of {list(cls._valueamember_map_.keys()				)}"""				)







class __snake_case    (						lowerCamelCase_		):
   lowerCAmelCase_														=							"longest"
   lowerCAmelCase_														=							"max_length"
   lowerCAmelCase_														=							"do_not_pad"







class __snake_case    (						lowerCamelCase_		):
   lowerCAmelCase_														=							"pt"
   lowerCAmelCase_														=							"tf"
   lowerCAmelCase_														=							"np"
   lowerCAmelCase_														=							"jax"







class __snake_case    :




   def __init__(   self      :    Optional[Any]	,     _lowercase      :    List[ContextManager]				):



     """simple docstring"""






     SCREAMING_SNAKE_CASE__      							=				context_managers
     SCREAMING_SNAKE_CASE__      							=				ExitStack()




   def __enter__(   self      :    str				):



     """simple docstring"""






     for context_manager in self.context_managers:
       self.stack.enter_context(_lowercase				)




   def __exit__(   self      :    Union[str, Any]	,     *_lowercase      :    Dict	,     **_lowercase      :    Dict				):



     """simple docstring"""






     self.stack.__exit__(*_lowercase	,     **_lowercase				)





def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	str     )							-> Union[str, Any]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__      							=				infer_framework(__UpperCamelCase     )
  if framework == "tf":
    SCREAMING_SNAKE_CASE__      							=				inspect.signature(model_class.call     )  # TensorFlow models
  elif framework == "pt":
    SCREAMING_SNAKE_CASE__      							=				inspect.signature(model_class.forward     )  # PyTorch models
  else:
    SCREAMING_SNAKE_CASE__      							=				inspect.signature(model_class.__call__     )  # Flax models

  for p in signature.parameters:
    if p == "return_loss" and signature.parameters[p].default is True:
      return True

  return False



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	Optional[Any]     )							-> Union[str, Any]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__      							=				model_class.__name__
  SCREAMING_SNAKE_CASE__      							=				infer_framework(__UpperCamelCase     )
  if framework == "tf":
    SCREAMING_SNAKE_CASE__      							=				inspect.signature(model_class.call     )  # TensorFlow models
  elif framework == "pt":
    SCREAMING_SNAKE_CASE__      							=				inspect.signature(model_class.forward     )  # PyTorch models
  else:
    SCREAMING_SNAKE_CASE__      							=				inspect.signature(model_class.__call__     )  # Flax models

  if "QuestionAnswering" in model_name:
    return [p for p in signature.parameters if "label" in p or p in ("start_positions", "end_positions")]
  else:
    return [p for p in signature.parameters if "label" in p]



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	MutableMapping			,					__UpperCamelCase   :	str = ""			,					__UpperCamelCase   :	str = "."     )							-> Union[str, Any]:







  """simple docstring"""





  def _flatten_dict(__UpperCamelCase   :	Any			,					__UpperCamelCase   :	Optional[Any]=""			,					__UpperCamelCase   :	int="."     ):
    for k, v in d.items():
      SCREAMING_SNAKE_CASE__      							=				str(__UpperCamelCase     ) + delimiter + str(__UpperCamelCase     ) if parent_key else k
      if v and isinstance(__UpperCamelCase			,					__UpperCamelCase     ):
        yield from flatten_dict(__UpperCamelCase			,					__UpperCamelCase			,					delimiter=__UpperCamelCase     ).items()
      else:
        yield key, v

  return dict(_flatten_dict(__UpperCamelCase			,					__UpperCamelCase			,					__UpperCamelCase     )     )



@contextmanager
def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	List[str]			,					__UpperCamelCase   :	bool = False     )							-> Any:







  """simple docstring"""





  if use_temp_dir:
    with tempfile.TemporaryDirectory() as tmp_dir:
      yield tmp_dir
  else:
    yield working_dir



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	List[Any]			,					__UpperCamelCase   :	Any=None     )							-> List[str]:







  """simple docstring"""





  if is_numpy_array(__UpperCamelCase     ):
    return np.transpose(__UpperCamelCase			,					axes=__UpperCamelCase     )
  elif is_torch_tensor(__UpperCamelCase     ):
    return array.T if axes is None else array.permute(*__UpperCamelCase     )
  elif is_tf_tensor(__UpperCamelCase     ):
    import tensorflow as tf

    return tf.transpose(__UpperCamelCase			,					perm=__UpperCamelCase     )
  elif is_jax_tensor(__UpperCamelCase     ):
    return jnp.transpose(__UpperCamelCase			,					axes=__UpperCamelCase     )
  else:
    raise ValueError(f"""Type not supported for transpose: {type(__UpperCamelCase     )}."""     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	List[str]			,					__UpperCamelCase   :	Any     )							-> List[str]:







  """simple docstring"""





  if is_numpy_array(__UpperCamelCase     ):
    return np.reshape(__UpperCamelCase			,					__UpperCamelCase     )
  elif is_torch_tensor(__UpperCamelCase     ):
    return array.reshape(*__UpperCamelCase     )
  elif is_tf_tensor(__UpperCamelCase     ):
    import tensorflow as tf

    return tf.reshape(__UpperCamelCase			,					__UpperCamelCase     )
  elif is_jax_tensor(__UpperCamelCase     ):
    return jnp.reshape(__UpperCamelCase			,					__UpperCamelCase     )
  else:
    raise ValueError(f"""Type not supported for reshape: {type(__UpperCamelCase     )}."""     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	Dict			,					__UpperCamelCase   :	Optional[Any]=None     )							-> int:







  """simple docstring"""





  if is_numpy_array(__UpperCamelCase     ):
    return np.squeeze(__UpperCamelCase			,					axis=__UpperCamelCase     )
  elif is_torch_tensor(__UpperCamelCase     ):
    return array.squeeze() if axis is None else array.squeeze(dim=__UpperCamelCase     )
  elif is_tf_tensor(__UpperCamelCase     ):
    import tensorflow as tf

    return tf.squeeze(__UpperCamelCase			,					axis=__UpperCamelCase     )
  elif is_jax_tensor(__UpperCamelCase     ):
    return jnp.squeeze(__UpperCamelCase			,					axis=__UpperCamelCase     )
  else:
    raise ValueError(f"""Type not supported for squeeze: {type(__UpperCamelCase     )}."""     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	Union[str, Any]			,					__UpperCamelCase   :	Optional[Any]     )							-> Optional[Any]:







  """simple docstring"""





  if is_numpy_array(__UpperCamelCase     ):
    return np.expand_dims(__UpperCamelCase			,					__UpperCamelCase     )
  elif is_torch_tensor(__UpperCamelCase     ):
    return array.unsqueeze(dim=__UpperCamelCase     )
  elif is_tf_tensor(__UpperCamelCase     ):
    import tensorflow as tf

    return tf.expand_dims(__UpperCamelCase			,					axis=__UpperCamelCase     )
  elif is_jax_tensor(__UpperCamelCase     ):
    return jnp.expand_dims(__UpperCamelCase			,					axis=__UpperCamelCase     )
  else:
    raise ValueError(f"""Type not supported for expand_dims: {type(__UpperCamelCase     )}."""     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	str     )							-> Any:







  """simple docstring"""





  if is_numpy_array(__UpperCamelCase     ):
    return np.size(__UpperCamelCase     )
  elif is_torch_tensor(__UpperCamelCase     ):
    return array.numel()
  elif is_tf_tensor(__UpperCamelCase     ):
    import tensorflow as tf

    return tf.size(__UpperCamelCase     )
  elif is_jax_tensor(__UpperCamelCase     ):
    return array.size
  else:
    raise ValueError(f"""Type not supported for expand_dims: {type(__UpperCamelCase     )}."""     )



def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	str			,					__UpperCamelCase   :	Union[str, Any]     )							-> int:







  """simple docstring"""





  for key, value in auto_map.items():
    if isinstance(__UpperCamelCase			,					(tuple, list)     ):
      SCREAMING_SNAKE_CASE__      							=				[f"""{repo_id}--{v}""" if (v is not None and """--""" not in v) else v for v in value]
    elif value is not None and "--" not in value:
      SCREAMING_SNAKE_CASE__      							=				f"""{repo_id}--{value}"""

  return auto_map






def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	List[Any]     )							-> Any:







  """simple docstring"""





  for base_class in inspect.getmro(__UpperCamelCase     ):
    SCREAMING_SNAKE_CASE__      							=				base_class.__module__
    SCREAMING_SNAKE_CASE__      							=				base_class.__name__
    if module.startswith("""tensorflow"""     ) or module.startswith("""keras"""     ) or name == "TFPreTrainedModel":
      return "tf"
    elif module.startswith("""torch"""     ) or name == "PreTrainedModel":
      return "pt"
    elif module.startswith("""flax"""     ) or module.startswith("""jax"""     ) or name == "FlaxPreTrainedModel":
      return "flax"
  else:
    raise TypeError(f"""Could not infer framework from class {model_class}."""     )

import os
from argparse import ArgumentParser
from typing import List

import torch.utils.data

from datasets import Dataset, IterableDataset
from datasets.distributed import split_dataset_by_node


__lowerCamelCase      :			int							       =		4
__lowerCamelCase      :			Dict							       =		3







class __snake_case    (						lowerCamelCase_		):
   pass





def      __SCREAMING_SNAKE_CASE  ( __UpperCamelCase   :	List[str]     )							-> List[str]:







  """simple docstring"""





  for shard in shards:
    for i in range(__UpperCamelCase     ):
      yield {"i": i, "shard": shard}



def      __SCREAMING_SNAKE_CASE  ( )							-> Union[str, Any]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__      							=				int(os.environ["""RANK"""]     )
  SCREAMING_SNAKE_CASE__      							=				int(os.environ["""WORLD_SIZE"""]     )

  SCREAMING_SNAKE_CASE__      							=				ArgumentParser()
  parser.add_argument("""--streaming"""			,					type=__UpperCamelCase     )
  parser.add_argument("""--local_rank"""			,					type=__UpperCamelCase     )
  parser.add_argument("""--num_workers"""			,					type=__UpperCamelCase			,					default=0     )
  SCREAMING_SNAKE_CASE__      							=				parser.parse_args()
  SCREAMING_SNAKE_CASE__      							=				args.streaming
  SCREAMING_SNAKE_CASE__      							=				args.num_workers

  SCREAMING_SNAKE_CASE__      							=				{"""shards""": [f"""shard_{shard_idx}""" for shard_idx in range(__UpperCamelCase     )]}
  SCREAMING_SNAKE_CASE__      							=				IterableDataset.from_generator(__UpperCamelCase			,					gen_kwargs=__UpperCamelCase     )
  if not streaming:
    SCREAMING_SNAKE_CASE__      							=				Dataset.from_list(list(__UpperCamelCase     )     )

  SCREAMING_SNAKE_CASE__      							=				split_dataset_by_node(__UpperCamelCase			,					rank=__UpperCamelCase			,					world_size=__UpperCamelCase     )
  SCREAMING_SNAKE_CASE__      							=				torch.utils.data.DataLoader(__UpperCamelCase			,					num_workers=__UpperCamelCase     )

  SCREAMING_SNAKE_CASE__      							=				NUM_SHARDS * NUM_ITEMS_PER_SHARD
  SCREAMING_SNAKE_CASE__      							=				full_size // world_size
  expected_local_size += int(rank < (full_size % world_size)     )

  SCREAMING_SNAKE_CASE__      							=				sum(1 for _ in dataloader     )
  if local_size != expected_local_size:
    raise FailedTestError(f"""local_size {local_size} != expected_local_size {expected_local_size}"""     )


if __name__ == "__main__":
   main()
