



"""simple docstring"""





def     __lowercase					(    a :				list[int]       ,		a :				int )					->					bool:
      __snake_case      :    Union[str, Any]  			=len(a )
      __snake_case      :    str  			=[[False] * (required_sum + 1) for _ in range(arr_len + 1 )]

      # for each arr value, a sum of zero(0) can be formed by not taking any element
      # hence True/1
      for i in range(arr_len + 1 ):
            __snake_case      :    Dict  			=True

      # sum is not zero and set is empty then false
      for i in range(1       ,		required_sum + 1 ):
            __snake_case      :    Any  			=False

      for i in range(1       ,		arr_len + 1 ):
            for j in range(1       ,		required_sum + 1 ):
                  if arr[i - 1] > j:
                        __snake_case      :    List[str]  			=subset[i - 1][j]
                  if arr[i - 1] <= j:
                        __snake_case      :    str  			=subset[i - 1][j] or subset[i - 1][j - arr[i - 1]]

      return subset[arr_len][required_sum]


if __name__ == "__main__":
    import doctest

    doctest.testmod()










"""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     __lowercase					(    a :				Dict )					->					str:
      return EnvironmentCommand()



def     __lowercase					(    a :				Optional[int] )					->					List[Any]:
      return EnvironmentCommand(args.accelerate_config_file )


class      _lowercase (     lowerCAmelCase						):


      @staticmethod
      def _UpperCamelCase						(    a				:	ArgumentParser						):





            """simple docstring"""







            __snake_case      :    Optional[int]  			=parser.add_parser('''env'''						)
            download_parser.set_defaults(func=a						)
            download_parser.add_argument(
                '''--accelerate-config_file'''							,   default=a							,   help='''The accelerate config file to use for the default values in the launching script.'''							,   )
            download_parser.set_defaults(func=a						)


      def __init__(    self				:	Any							,   a				:	str							,   *a				:	Any						):





            """simple docstring"""







            __snake_case      :    int  			=accelerate_config_file


      def _UpperCamelCase						(    self				:	List[str]						):





            """simple docstring"""







            __snake_case      :    List[str]  			='''not installed'''
            if is_safetensors_available():
                  import safetensors

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

                  __snake_case      :    List[Any]  			=f'''{safetensors.__version__} but is ignored because of PyTorch version too old.'''

            __snake_case      :    Dict  			='''not installed'''
            __snake_case      :    Optional[Any]  			='''not found'''
            if is_accelerate_available():
                  import accelerate
                  from accelerate.commands.config import default_config_file, load_config_from_file

                  __snake_case      :    Union[str, Any]  			=accelerate.__version__
                  # Get the default from the config file.
                  if self._accelerate_config_file is not None or os.path.isfile(a						):
                        __snake_case      :    int  			=load_config_from_file(self._accelerate_config_file						).to_dict()

                  __snake_case      :    Optional[int]  			=(
                      '''\n'''.join([f'''\t- {prop}: {val}''' for prop, val in accelerate_config.items()]						)
                      if isinstance(a							,   a						)
                      else f'''\t{accelerate_config}'''
                  )

            __snake_case      :    int  			='''not installed'''
            __snake_case      :    Any  			='''NA'''
            if is_torch_available():
                  import torch

                  __snake_case      :    Tuple  			=torch.__version__
                  __snake_case      :    Optional[Any]  			=torch.cuda.is_available()

            __snake_case      :    Optional[Any]  			='''not installed'''
            __snake_case      :    Any  			='''NA'''
            if is_tf_available():
                  import tensorflow as tf

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

            __snake_case      :    Optional[int]  			='''not installed'''
            __snake_case      :    Dict  			='''not installed'''
            __snake_case      :    List[str]  			='''not installed'''
            __snake_case      :    Optional[int]  			='''NA'''
            if is_flax_available():
                  import flax
                  import jax
                  import jaxlib

                  __snake_case      :    Tuple  			=flax.__version__
                  __snake_case      :    Optional[Any]  			=jax.__version__
                  __snake_case      :    str  			=jaxlib.__version__
                  __snake_case      :    Tuple  			=jax.lib.xla_bridge.get_backend().platform

            __snake_case      :    List[str]  			={
                '''`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(a						)						)

            return info







      @staticmethod
      def _UpperCamelCase						(    a				:	List[str]						):





            """simple docstring"""







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


