
'''simple docstring'''


from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Mapping, Optional

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


if TYPE_CHECKING:
   from ... import FeatureExtractionMixin, TensorType

snake_case_ :  Any     =					logging.get_logger(__name__)

snake_case_ :  str     =					{
    'openai/imagegpt-small': '',
    'openai/imagegpt-medium': '',
    'openai/imagegpt-large': '',
}


class 						lowercase__	(  snake_case_   ):






   '''simple docstring'''







   _snake_case		   =							'''imagegpt'''
   _snake_case		   =							['''past_key_values''']
   _snake_case		   =							{
       '''hidden_size''': '''n_embd''',
       '''max_position_embeddings''': '''n_positions''',
       '''num_attention_heads''': '''n_head''',
       '''num_hidden_layers''': '''n_layer''',
   }







   def __init__(			self ,   lowerCamelCase__=5_1_2 + 1 ,   lowerCamelCase__=3_2 * 3_2 ,   lowerCamelCase__=5_1_2 ,   lowerCamelCase__=2_4 ,   lowerCamelCase__=8 ,   lowerCamelCase__=None ,   lowerCamelCase__="quick_gelu" ,   lowerCamelCase__=0.1 ,   lowerCamelCase__=0.1 ,   lowerCamelCase__=0.1 ,   lowerCamelCase__=1e-5 ,   lowerCamelCase__=0.02 ,   lowerCamelCase__=True ,   lowerCamelCase__=True ,   lowerCamelCase__=False ,   lowerCamelCase__=False ,   lowerCamelCase__=False ,   **lowerCamelCase__ ,   ):

      '''simple docstring'''







      UpperCamelCase       =  vocab_size
      UpperCamelCase       =  n_positions
      UpperCamelCase       =  n_embd
      UpperCamelCase       =  n_layer
      UpperCamelCase       =  n_head
      UpperCamelCase       =  n_inner
      UpperCamelCase       =  activation_function
      UpperCamelCase       =  resid_pdrop
      UpperCamelCase       =  embd_pdrop
      UpperCamelCase       =  attn_pdrop
      UpperCamelCase       =  layer_norm_epsilon
      UpperCamelCase       =  initializer_range
      UpperCamelCase       =  scale_attn_weights
      UpperCamelCase       =  use_cache
      UpperCamelCase       =  scale_attn_by_inverse_layer_idx
      UpperCamelCase       =  reorder_and_upcast_attn
      UpperCamelCase       =  tie_word_embeddings

      super().__init__(tie_word_embeddings=lowerCamelCase__ ,   **lowerCamelCase__   )




class 						lowercase__	(  snake_case_   ):






   '''simple docstring'''







   @property
   def       UpperCAmelCase				(			self   ):

      '''simple docstring'''







      return OrderedDict(
          [
              ('''input_ids''', {0: '''batch''', 1: '''sequence'''}),
          ]   )







   def       UpperCAmelCase				(			self ,   lowerCamelCase__ ,   lowerCamelCase__ = 1 ,   lowerCamelCase__ = -1 ,   lowerCamelCase__ = False ,   lowerCamelCase__ = None ,   lowerCamelCase__ = 3 ,   lowerCamelCase__ = 3_2 ,   lowerCamelCase__ = 3_2 ,   ):

      '''simple docstring'''







      UpperCamelCase       =  self._generate_dummy_images(lowerCamelCase__ ,   lowerCamelCase__ ,   lowerCamelCase__ ,   lowerCamelCase__   )
      UpperCamelCase       =  dict(preprocessor(images=lowerCamelCase__ ,   return_tensors=lowerCamelCase__   )   )

      return inputs







'''simple docstring'''


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

import torch_xla.distributed.xla_multiprocessing as xmp



def  __snake_case     (    ):
   UpperCamelCase       =  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=_UpperCAmelCase,      default=1,      help='''Number of TPU cores to use (1 or 8).''')

   # positional
   parser.add_argument(
       '''training_script''',      type=_UpperCAmelCase,      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=_UpperCAmelCase)

   return parser.parse_args()



def  __snake_case     (    ):
   UpperCamelCase       =  parse_args()

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

   # Patch sys.argv
   UpperCamelCase       =  [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()





