





'''simple docstring'''







import importlib.util
import os
import platform
from argparse import ArgumentParser

import huggingface_hub

from .. import __version__ as version
from ..utils import (
    is_accelerate_available,
    is_flax_available,
    is_safetensors_available,
    is_tf_available,
    is_torch_available,
)
from . import BaseTransformersCLICommand





def 				lowerCamelCase_					(     SCREAMING_SNAKE_CASE__					:	Union[str, Any]      )       ->		Tuple:
						return EnvironmentCommand()





def 				lowerCamelCase_					(     SCREAMING_SNAKE_CASE__					:	Tuple      )       ->		int:
						return EnvironmentCommand(args.accelerate_config_file      )


class     __a					(_lowerCamelCase   ):

							@staticmethod
							def 			UpperCAmelCase__		(							__magic_name__							:   ArgumentParser      )    ->				Dict:







													"""simple docstring"""
													UpperCAmelCase_	:					Optional[Any]     =     parser.add_parser('''env'''      )
													download_parser.set_defaults(func=_UpperCamelCase      )
													download_parser.add_argument(
													    '''--accelerate-config_file'''				,   default=_UpperCamelCase				,   help='''The accelerate config file to use for the default values in the launching script.'''				,   )
													download_parser.set_defaults(func=_UpperCamelCase      )

							def __init__(							self							:   Tuple				,   __magic_name__							:   Dict				,   *__magic_name__							:   Optional[int]      )    ->				None:







													"""simple docstring"""
													UpperCAmelCase_	:					Optional[int]     =     accelerate_config_file

							def 			UpperCAmelCase__		(							self							:   Dict      )    ->				List[str]:







													"""simple docstring"""
													UpperCAmelCase_	:					List[Any]     =     '''not installed'''
													if is_safetensors_available():
																			import safetensors

																			UpperCAmelCase_	:					Tuple     =     safetensors.__version__
													elif importlib.util.find_spec('''safetensors'''      ) is not None:
																			import safetensors

																			UpperCAmelCase_	:					Dict     =     F"""{safetensors.__version__} but is ignored because of PyTorch version too old."""

													UpperCAmelCase_	:					int     =     '''not installed'''
													UpperCAmelCase_	:					Any     =     '''not found'''
													if is_accelerate_available():
																			import accelerate
																			from accelerate.commands.config import default_config_file, load_config_from_file

																			UpperCAmelCase_	:					List[str]     =     accelerate.__version__
																			# Get the default from the config file.
																			if self._accelerate_config_file is not None or os.path.isfile(_UpperCamelCase      ):
																									UpperCAmelCase_	:					int     =     load_config_from_file(self._accelerate_config_file      ).to_dict()

																			UpperCAmelCase_	:					Dict     =     (
																			    '''\n'''.join([F"""\t- {prop}: {val}""" for prop, val in accelerate_config.items()]      )
																			    if isinstance(_UpperCamelCase				,   _UpperCamelCase      )
																			    else F"""\t{accelerate_config}"""
																			)

													UpperCAmelCase_	:					Optional[Any]     =     '''not installed'''
													UpperCAmelCase_	:					List[str]     =     '''NA'''
													if is_torch_available():
																			import torch

																			UpperCAmelCase_	:					Optional[Any]     =     torch.__version__
																			UpperCAmelCase_	:					int     =     torch.cuda.is_available()

													UpperCAmelCase_	:					Dict     =     '''not installed'''
													UpperCAmelCase_	:					Tuple     =     '''NA'''
													if is_tf_available():
																			import tensorflow as tf

																			UpperCAmelCase_	:					Any     =     tf.__version__
																			try:
																									# deprecated in v2.1
																									UpperCAmelCase_	:					Dict     =     tf.test.is_gpu_available()
																			except AttributeError:
																									# returns list of devices, convert to bool
																									UpperCAmelCase_	:					List[str]     =     bool(tf.config.list_physical_devices('''GPU'''      )      )

													UpperCAmelCase_	:					Union[str, Any]     =     '''not installed'''
													UpperCAmelCase_	:					Optional[int]     =     '''not installed'''
													UpperCAmelCase_	:					str     =     '''not installed'''
													UpperCAmelCase_	:					str     =     '''NA'''
													if is_flax_available():
																			import flax
																			import jax
																			import jaxlib

																			UpperCAmelCase_	:					Optional[int]     =     flax.__version__
																			UpperCAmelCase_	:					Optional[Any]     =     jax.__version__
																			UpperCAmelCase_	:					Dict     =     jaxlib.__version__
																			UpperCAmelCase_	:					Any     =     jax.lib.xla_bridge.get_backend().platform

													UpperCAmelCase_	:					Dict     =     {
													    '''`transformers` version''': version,
													    '''Platform''': platform.platform(),
													    '''Python version''': platform.python_version(),
													    '''Huggingface_hub version''': huggingface_hub.__version__,
													    '''Safetensors version''': F"""{safetensors_version}""",
													    '''Accelerate version''': F"""{accelerate_version}""",
													    '''Accelerate config''': F"""{accelerate_config_str}""",
													    '''PyTorch version (GPU?)''': F"""{pt_version} ({pt_cuda_available})""",
													    '''Tensorflow version (GPU?)''': F"""{tf_version} ({tf_cuda_available})""",
													    '''Flax version (CPU?/GPU?/TPU?)''': F"""{flax_version} ({jax_backend})""",
													    '''Jax version''': F"""{jax_version}""",
													    '''JaxLib version''': F"""{jaxlib_version}""",
													    '''Using GPU in script?''': '''<fill in>''',
													    '''Using distributed or parallel set-up in script?''': '''<fill in>''',
													}

													print('''\nCopy-and-paste the text below in your GitHub issue and FILL OUT the two last points.\n'''      )
													print(self.format_dict(_UpperCamelCase      )      )

													return info



							@staticmethod
							def 			UpperCAmelCase__		(							__magic_name__							:   Union[str, Any]      )    ->				List[str]:







													"""simple docstring"""
													return "\n".join([F"""- {prop}: {val}""" for prop, val in d.items()]      ) + "\n"












# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


snake_case__					:							List[str]													=     {
    'configuration_vivit': ['VIVIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'VivitConfig'],
}
try:
       if not is_vision_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       snake_case__					:							Tuple													=     ['VivitImageProcessor']


try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       snake_case__					:							Any													=     [
           'VIVIT_PRETRAINED_MODEL_ARCHIVE_LIST',
           'VivitModel',
           'VivitPreTrainedModel',
           'VivitForVideoClassification',
       ]


if TYPE_CHECKING:
       from .configuration_vivit import VIVIT_PRETRAINED_CONFIG_ARCHIVE_MAP, VivitConfig

       try:
              if not is_vision_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .image_processing_vivit import VivitImageProcessor

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_vivit import (
                  VIVIT_PRETRAINED_MODEL_ARCHIVE_LIST,
                  VivitForVideoClassification,
                  VivitModel,
                  VivitPreTrainedModel,
              )


else:
       import sys

       snake_case__					:							List[str]													=     _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)





