from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
class     lowerCAmelCase_     (       __lowercase ):
							UpperCAmelCase				   =     ["image_processor", "tokenizer"]
							UpperCAmelCase				   =     "AutoImageProcessor"
							UpperCAmelCase				   =     "AutoTokenizer"







							def __init__(   self      :     Union[str, Any] ,			_A      :     Dict ,			_A      :     Union[str, Any]		):
												super().__init__(_A ,			_A		)
												_UpperCamelCase			     =     self.image_processor







							def __call__(   self      :     int ,			_A      :     Tuple=None ,			_A      :     Tuple=None ,			_A      :     List[Any]=None ,			**_A      :     Dict		):

												if text is None and images is None:
																	raise ValueError('''You have to specify either text or images. Both cannot be none.'''		)

												if text is not None:
																	_UpperCamelCase			     =     self.tokenizer(_A ,			return_tensors=_A ,			**_A		)

												if images is not None:
																	_UpperCamelCase			     =     self.image_processor(_A ,			return_tensors=_A ,			**_A		)

												if text is not None and images is not None:
																	_UpperCamelCase			     =     image_features.pixel_values
																	return encoding
												elif text is not None:
																	return encoding
												else:
																	return BatchEncoding(data=dict(**_A		) ,			tensor_type=_A		)







							def  UpperCamelCase_						(   self      :     Any ,			*_A      :     List[Any] ,			**_A      :     str		):
												return self.tokenizer.batch_decode(*_A ,			**_A		)







							def  UpperCamelCase_						(   self      :     Any ,			*_A      :     int ,			**_A      :     Dict		):
												return self.tokenizer.decode(*_A ,			**_A		)







							@property
							def  UpperCamelCase_						(   self      :     Union[str, Any]		):
												return ["input_ids", "attention_mask", "pixel_values"]





import operator as op


lowerCamelCase		       =      """scaler.pt"""
lowerCamelCase		       =      """pytorch_model"""
lowerCamelCase		       =      """random_states"""
lowerCamelCase		       =      """optimizer"""
lowerCamelCase		       =      """scheduler"""
lowerCamelCase		       =      """pytorch_model.bin"""
lowerCamelCase		       =      """pytorch_model.bin.index.json"""
lowerCamelCase		       =      """model.safetensors"""
lowerCamelCase		       =      """model.safetensors.index.json"""
lowerCamelCase		       =      """1.10.2"""
lowerCamelCase		       =      """py38"""
lowerCamelCase		       =      """4.17.0"""
lowerCamelCase		       =      ["""ml.p3.16xlarge""", """ml.p3dn.24xlarge""", """ml.p4dn.24xlarge"""]
lowerCamelCase		       =      ["""FULL_SHARD""", """SHARD_GRAD_OP""", """NO_SHARD""", """HYBRID_SHARD""", """HYBRID_SHARD_ZERO2"""]
lowerCamelCase		       =      ["""TRANSFORMER_BASED_WRAP""", """SIZE_BASED_WRAP""", """NO_WRAP"""]
lowerCamelCase		       =      ["""BACKWARD_PRE""", """BACKWARD_POST""", """NO_PREFETCH"""]
lowerCamelCase		       =      ["""FULL_STATE_DICT""", """LOCAL_STATE_DICT""", """SHARDED_STATE_DICT"""]
lowerCamelCase		       =      """2.0.1"""
lowerCamelCase		       =      ["""pdsh""", """standard""", """openmpi""", """mvapich"""]
lowerCamelCase		       =      ["""default""", """reduce-overhead""", """max-autotune"""]

lowerCamelCase		       =      {""">""": op.gt, """>=""": op.ge, """==""": op.eq, """!=""": op.ne, """<=""": op.le, """<""": op.lt}

# These are the args for `torch.distributed.launch` for pytorch < 1.9
lowerCamelCase		       =      [
    """nnodes""",
    """nproc_per_node""",
    """rdzv_backend""",
    """rdzv_endpoint""",
    """rdzv_id""",
    """rdzv_conf""",
    """standalone""",
    """max_restarts""",
    """monitor_interval""",
    """start_method""",
    """role""",
    """module""",
    """m""",
    """no_python""",
    """run_path""",
    """log_dir""",
    """r""",
    """redirects""",
    """t""",
    """tee""",
    """node_rank""",
    """master_addr""",
    """master_port""",
]

lowerCamelCase		       =      ["""DEEPSPEED""", """MULTI_GPU""", """FSDP""", """MEGATRON_LM"""]
lowerCamelCase		       =      ["""DEEPSPEED""", """MULTI_XPU""", """FSDP"""]


