

import copy
import fnmatch
import json
import os
import pickle as pkl
import shutil
import sys
import tarfile
import tempfile
from collections import OrderedDict
from contextlib import contextmanager
from functools import partial
from hashlib import shaaaa
from io import BytesIO
from pathlib import Path
from urllib.parse import urlparse
from zipfile import ZipFile, is_zipfile

import cva
import numpy as np
import requests
import wget
from filelock import FileLock
from PIL import Image
from tqdm.auto import tqdm
from yaml import Loader, dump, load


try:
     import torch

     __lowercase     : Tuple       =						True
except ImportError:
     __lowercase     : Union[str, Any]       =						False


try:
     from torch.hub import _get_torch_home

     __lowercase     : Tuple       =						_get_torch_home()
except ImportError:
     __lowercase     : Union[str, Any]       =						os.path.expanduser(
         os.getenv('''TORCH_HOME''', os.path.join(os.getenv('''XDG_CACHE_HOME''', '''~/.cache'''), '''torch'''))
     )

__lowercase     : Optional[Any]       =						os.path.join(torch_cache_home, '''transformers''')

__lowercase     : Dict       =						'''https://cdn.huggingface.co'''
__lowercase     : Union[str, Any]       =						'''https://s3.amazonaws.com/models.huggingface.co/bert'''
__lowercase     : Any       =						'''/'''.join(str(Path(__file__).resolve()).split('''/''')[:-1])
__lowercase     : Optional[int]       =						os.path.join(PATH, '''config.yaml''')
__lowercase     : List[str]       =						os.path.join(PATH, '''attributes.txt''')
__lowercase     : int       =						os.path.join(PATH, '''objects.txt''')
__lowercase     : str       =						os.getenv('''PYTORCH_PRETRAINED_BERT_CACHE''', default_cache_path)
__lowercase     : int       =						os.getenv('''PYTORCH_TRANSFORMERS_CACHE''', PYTORCH_PRETRAINED_BERT_CACHE)
__lowercase     : Dict       =						os.getenv('''TRANSFORMERS_CACHE''', PYTORCH_TRANSFORMERS_CACHE)
__lowercase     : List[Any]       =						'''pytorch_model.bin'''
__lowercase     : Optional[Any]       =						'''config.yaml'''







def       lowercase					(	__A :					int=OBJECTS ,    __A :					Dict=ATTRIBUTES		)				->			Optional[int]:





    '''simple docstring'''




    snake_case							:		Optional[Any]        =		[]
    with open(__A		) as f:
        for object in f.readlines():
            vg_classes.append(object.split(""","""		)[0].lower().strip()		)

    snake_case							:		Union[str, Any]        =		[]
    with open(__A		) as f:
        for object in f.readlines():
            vg_attrs.append(object.split(""","""		)[0].lower().strip()		)
    return vg_classes, vg_attrs







def       lowercase					(	__A :					str		)				->			Tuple:





    '''simple docstring'''




    snake_case							:		str        =		OrderedDict()
    with open(__A ,    """rb"""		) as f:
        snake_case							:		Tuple        =		pkl.load(__A		)["""model"""]
    for k in copy.deepcopy(list(ckp.keys()		)		):
        snake_case							:		Optional[Any]        =		ckp.pop(__A		)
        if isinstance(__A ,    np.ndarray		):
            snake_case							:		int        =		torch.tensor(__A		)
        else:
            assert isinstance(__A ,    torch.tensor		), type(__A		)
        snake_case							:		Optional[Any]        =		v
    return r



class 						_A     :





  '''simple docstring'''



  __lowerCamelCase			:      Union[str, Any]					=   {}





  def __init__(  self   ,SCREAMING_SNAKE_CASE_   ,SCREAMING_SNAKE_CASE_ = "root"   ,SCREAMING_SNAKE_CASE_=0    ):

      '''simple docstring'''
      snake_case							:		Any        =		name
      snake_case							:		Union[str, Any]        =		level
      snake_case							:		int        =		{}
      for k, v in dictionary.items():
          if v is None:
              raise ValueError()
          snake_case							:		Optional[Any]        =		copy.deepcopy(SCREAMING_SNAKE_CASE_    )
          snake_case							:		List[str]        =		copy.deepcopy(SCREAMING_SNAKE_CASE_    )
          if isinstance(SCREAMING_SNAKE_CASE_   ,SCREAMING_SNAKE_CASE_    ):
              snake_case							:		Any        =		Config(SCREAMING_SNAKE_CASE_   ,name=SCREAMING_SNAKE_CASE_   ,level=level + 1    )
          snake_case							:		Tuple        =		v
          setattr(self   ,SCREAMING_SNAKE_CASE_   ,SCREAMING_SNAKE_CASE_    )

      snake_case							:		Optional[int]        =		d





  def __repr__(  self    ):

      '''simple docstring'''
      return str(list((self._pointer.keys())    )    )





  def __setattr__(  self   ,SCREAMING_SNAKE_CASE_   ,SCREAMING_SNAKE_CASE_    ):

      '''simple docstring'''
      snake_case							:		List[str]        =		val
      snake_case							:		Any        =		val
      snake_case							:		Tuple        =		key.split("""."""    )
      snake_case							:		List[str]        =		len(SCREAMING_SNAKE_CASE_    ) - 1
      snake_case							:		str        =		self._pointer
      if len(SCREAMING_SNAKE_CASE_    ) > 1:
          for i, l in enumerate(SCREAMING_SNAKE_CASE_    ):
              if hasattr(self   ,SCREAMING_SNAKE_CASE_    ) and isinstance(getattr(self   ,SCREAMING_SNAKE_CASE_    )   ,SCREAMING_SNAKE_CASE_    ):
                  setattr(getattr(self   ,SCREAMING_SNAKE_CASE_    )   ,""".""".join(levels[i:]    )   ,SCREAMING_SNAKE_CASE_    )
              if l == last_level:
                  snake_case							:		List[Any]        =		val
              else:
                  snake_case							:		Optional[int]        =		pointer[l]





  def    snake_case_       (  self    ):

      '''simple docstring'''
      return self._pointer





  def    snake_case_       (  self   ,SCREAMING_SNAKE_CASE_   ,SCREAMING_SNAKE_CASE_    ):

      '''simple docstring'''
      with open(F"""{file_name}"""   ,"""w"""    ) as stream:
          dump(SCREAMING_SNAKE_CASE_   ,SCREAMING_SNAKE_CASE_    )





  def    snake_case_       (  self   ,SCREAMING_SNAKE_CASE_   ,SCREAMING_SNAKE_CASE_    ):

      '''simple docstring'''
      with open(F"""{file_name}"""   ,"""w"""    ) as stream:
          json.dump(SCREAMING_SNAKE_CASE_   ,SCREAMING_SNAKE_CASE_    )





  @staticmethod
  def    snake_case_       (  SCREAMING_SNAKE_CASE_    ):

      '''simple docstring'''
      with open(SCREAMING_SNAKE_CASE_    ) as stream:
          snake_case							:		Optional[int]        =		load(SCREAMING_SNAKE_CASE_   ,Loader=SCREAMING_SNAKE_CASE_    )
      return data





  def __str__(  self    ):

      '''simple docstring'''
      snake_case							:		Tuple        =		"""    """
      if self._name != "root":
          snake_case							:		List[str]        =		F"""{t * (self._level-1)}{self._name}:\n"""
      else:
          snake_case							:		Dict        =		""""""
      snake_case							:		Dict        =		self._level
      for i, (k, v) in enumerate(self._pointer.items()    ):
          if isinstance(SCREAMING_SNAKE_CASE_   ,SCREAMING_SNAKE_CASE_    ):
              r += F"""{t * (self._level)}{v}\n"""
              self._level += 1
          else:
              r += F"""{t * (self._level)}{k}: {v} ({type(SCREAMING_SNAKE_CASE_    ).__name__})\n"""
          snake_case							:		Tuple        =		level
      return r[:-1]





  @classmethod
  def    snake_case_       (  cls   ,SCREAMING_SNAKE_CASE_   ,**SCREAMING_SNAKE_CASE_    ):

      '''simple docstring'''
      snake_case      ,		snake_case							:		str        =		cls.get_config_dict(SCREAMING_SNAKE_CASE_   ,**SCREAMING_SNAKE_CASE_    )
      return cls(SCREAMING_SNAKE_CASE_    )





  @classmethod
  def    snake_case_       (  cls   ,SCREAMING_SNAKE_CASE_   ,**SCREAMING_SNAKE_CASE_    ):

      '''simple docstring'''
      snake_case							:		int        =		kwargs.pop("""cache_dir"""   ,SCREAMING_SNAKE_CASE_    )
      snake_case							:		Dict        =		kwargs.pop("""force_download"""   ,SCREAMING_SNAKE_CASE_    )
      snake_case							:		Dict        =		kwargs.pop("""resume_download"""   ,SCREAMING_SNAKE_CASE_    )
      snake_case							:		Optional[Any]        =		kwargs.pop("""proxies"""   ,SCREAMING_SNAKE_CASE_    )
      snake_case							:		Any        =		kwargs.pop("""local_files_only"""   ,SCREAMING_SNAKE_CASE_    )

      if os.path.isdir(SCREAMING_SNAKE_CASE_    ):
          snake_case							:		Optional[int]        =		os.path.join(SCREAMING_SNAKE_CASE_   ,SCREAMING_SNAKE_CASE_    )
      elif os.path.isfile(SCREAMING_SNAKE_CASE_    ) or is_remote_url(SCREAMING_SNAKE_CASE_    ):
          snake_case							:		Tuple        =		pretrained_model_name_or_path
      else:
          snake_case							:		List[Any]        =		hf_bucket_url(SCREAMING_SNAKE_CASE_   ,filename=SCREAMING_SNAKE_CASE_   ,use_cdn=SCREAMING_SNAKE_CASE_    )

      try:
          # Load from URL or cache if already cached
          snake_case							:		Optional[int]        =		cached_path(
              SCREAMING_SNAKE_CASE_   ,cache_dir=SCREAMING_SNAKE_CASE_   ,force_download=SCREAMING_SNAKE_CASE_   ,proxies=SCREAMING_SNAKE_CASE_   ,resume_download=SCREAMING_SNAKE_CASE_   ,local_files_only=SCREAMING_SNAKE_CASE_   ,)
          # Load config dict
          if resolved_config_file is None:
              raise EnvironmentError

          snake_case							:		List[str]        =		Config.load_yaml(SCREAMING_SNAKE_CASE_    )

      except EnvironmentError:
          snake_case							:		List[Any]        =		"""Can't load config for"""
          raise EnvironmentError(SCREAMING_SNAKE_CASE_    )

      if resolved_config_file == config_file:
          print("""loading configuration file from path"""    )
      else:
          print("""loading configuration file cache"""    )

      return Config.load_yaml(SCREAMING_SNAKE_CASE_    ), kwargs







def       lowercase					(	__A :					List[str]		)				->			List[str]:





    '''simple docstring'''




    snake_case							:		Union[str, Any]        =		torch.load("""dump.pt""" ,    map_location=in_tensor.device		)
    snake_case							:		int        =		in_tensor.numpy()
    snake_case							:		int        =		out_tensor.numpy()[0]
    print(na.shape ,    na[0, 0, :5]		)
    print(na.shape ,    na[0, 0, :5]		)
    assert np.allclose(__A ,    __A ,    rtol=0.01 ,    atol=0.1		), (
        f"""{sum([1 for x in np.isclose(__A ,    __A ,    rtol=0.01 ,    atol=0.1		).flatten() if x is False]		)/len(na.flatten()		)*100:.4f} %"""
        " element-wise mismatch"
    )
    raise Exception("""tensors are all good"""		)

    # Hugging face functions below







def       lowercase					(	__A :					str		)				->			Any:





    '''simple docstring'''




    snake_case							:		int        =		urlparse(__A		)
    return parsed.scheme in ("http", "https")







def       lowercase					(	__A :					str ,    __A :					str ,    __A :					Union[str, Any]=True		)				->			str:





    '''simple docstring'''




    snake_case							:		Optional[Any]        =		CLOUDFRONT_DISTRIB_PREFIX if use_cdn else S3_BUCKET_PREFIX
    snake_case							:		Optional[int]        =		"""/""" not in model_id
    if legacy_format:
        return f"""{endpoint}/{model_id}-{filename}"""
    else:
        return f"""{endpoint}/{model_id}/{filename}"""







def       lowercase					(	__A :					Union[str, Any] ,    __A :					int ,    __A :					Dict=None ,    __A :					List[Any]=0 ,    __A :					Dict=None ,    )				->			Optional[Any]:





    '''simple docstring'''




    snake_case							:		Optional[Any]        =		"""python/{}""".format(sys.version.split()[0]		)
    if _torch_available:
        ua += "; torch/{}".format(torch.__version__		)
    if isinstance(__A ,    __A		):
        ua += "; " + "; ".join("""{}/{}""".format(__A ,    __A		) for k, v in user_agent.items()		)
    elif isinstance(__A ,    __A		):
        ua += "; " + user_agent
    snake_case							:		int        =		{"""user-agent""": ua}
    if resume_size > 0:
        snake_case							:		int        =		"""bytes=%d-""" % (resume_size,)
    snake_case							:		List[Any]        =		requests.get(__A ,    stream=__A ,    proxies=__A ,    headers=__A		)
    if response.status_code == 416:  # Range not satisfiable
        return
    snake_case							:		Optional[int]        =		response.headers.get("""Content-Length"""		)
    snake_case							:		int        =		resume_size + int(__A		) if content_length is not None else None
    snake_case							:		List[Any]        =		tqdm(
        unit="""B""" ,    unit_scale=__A ,    total=__A ,    initial=__A ,    desc="""Downloading""" ,    )
    for chunk in response.iter_content(chunk_size=1024		):
        if chunk:  # filter out keep-alive new chunks
            progress.update(len(__A		)		)
            temp_file.write(__A		)
    progress.close()







def       lowercase					(	__A :					Tuple ,    __A :					Tuple=None ,    __A :					str=False ,    __A :					Union[str, Any]=None ,    __A :					Optional[Any]=10 ,    __A :					int=False ,    __A :					Dict=None ,    __A :					Optional[int]=False ,    )				->			Dict:





    '''simple docstring'''




    if cache_dir is None:
        snake_case							:		List[Any]        =		TRANSFORMERS_CACHE
    if isinstance(__A ,    __A		):
        snake_case							:		str        =		str(__A		)

    os.makedirs(__A ,    exist_ok=__A		)

    snake_case							:		List[str]        =		None
    if not local_files_only:
        try:
            snake_case							:		int        =		requests.head(__A ,    allow_redirects=__A ,    proxies=__A ,    timeout=__A		)
            if response.status_code == 200:
                snake_case							:		Dict        =		response.headers.get("""ETag"""		)
        except (EnvironmentError, requests.exceptions.Timeout):
            # etag is already None
            pass

    snake_case							:		Optional[int]        =		url_to_filename(__A ,    __A		)

    # get cache path to put the file
    snake_case							:		Any        =		os.path.join(__A ,    __A		)

    # etag is None = we don't have a connection, or url doesn't exist, or is otherwise inaccessible.
    # try to get the last downloaded one
    if etag is None:
        if os.path.exists(__A		):
            return cache_path
        else:
            snake_case							:		Tuple        =		[
                file
                for file in fnmatch.filter(os.listdir(__A		) ,    filename + """.*"""		)
                if not file.endswith(""".json"""		) and not file.endswith(""".lock"""		)
            ]
            if len(__A		) > 0:
                return os.path.join(__A ,    matching_files[-1]		)
            else:
                # If files cannot be found and local_files_only=True,
                # the models might've been found if local_files_only=False
                # Notify the user about that
                if local_files_only:
                    raise ValueError(
                        """Cannot find the requested files in the cached path and outgoing traffic has been"""
                        """ disabled. To enable model look-ups and downloads online, set 'local_files_only'"""
                        """ to False."""		)
                return None

    # From now on, etag is not None.
    if os.path.exists(__A		) and not force_download:
        return cache_path

    # Prevent parallel downloads of the same file with a lock.
    snake_case							:		Dict        =		cache_path + """.lock"""
    with FileLock(__A		):
        # If the download just completed while the lock was activated.
        if os.path.exists(__A		) and not force_download:
            # Even if returning early like here, the lock will be released.
            return cache_path

        if resume_download:
            snake_case							:		int        =		cache_path + """.incomplete"""

            @contextmanager
            def _resumable_file_manager():
                with open(__A ,    """a+b"""		) as f:
                    yield f

            snake_case							:		List[str]        =		_resumable_file_manager
            if os.path.exists(__A		):
                snake_case							:		Dict        =		os.stat(__A		).st_size
            else:
                snake_case							:		Optional[int]        =		0
        else:
            snake_case							:		Dict        =		partial(tempfile.NamedTemporaryFile ,    dir=__A ,    delete=__A		)
            snake_case							:		Optional[int]        =		0

        # Download to temporary file, then copy to cache dir once finished.
        # Otherwise you get corrupt cache entries if the download gets interrupted.
        with temp_file_manager() as temp_file:
            print(
                """%s not found in cache or force_download set to True, downloading to %s""" ,    __A ,    temp_file.name ,    )

            http_get(
                __A ,    __A ,    proxies=__A ,    resume_size=__A ,    user_agent=__A ,    )

        os.replace(temp_file.name ,    __A		)

        snake_case							:		Any        =		{"""url""": url, """etag""": etag}
        snake_case							:		Dict        =		cache_path + """.json"""
        with open(__A ,    """w"""		) as meta_file:
            json.dump(__A ,    __A		)

    return cache_path







def       lowercase					(	__A :					Optional[int] ,    __A :					List[Any]=None		)				->			str:





    '''simple docstring'''




    snake_case							:		List[Any]        =		url.encode("""utf-8"""		)
    snake_case							:		str        =		shaaaa(__A		)
    snake_case							:		Optional[Any]        =		url_hash.hexdigest()

    if etag:
        snake_case							:		str        =		etag.encode("""utf-8"""		)
        snake_case							:		Optional[Any]        =		shaaaa(__A		)
        filename += "." + etag_hash.hexdigest()

    if url.endswith(""".h5"""		):
        filename += ".h5"

    return filename







def       lowercase					(	__A :					Optional[int] ,    __A :					List[str]=None ,    __A :					Union[str, Any]=False ,    __A :					Optional[int]=None ,    __A :					Union[str, Any]=False ,    __A :					Union[str, Any]=None ,    __A :					List[str]=False ,    __A :					str=False ,    __A :					Union[str, Any]=False ,    )				->			List[str]:





    '''simple docstring'''




    if cache_dir is None:
        snake_case							:		Any        =		TRANSFORMERS_CACHE
    if isinstance(__A ,    __A		):
        snake_case							:		Tuple        =		str(__A		)
    if isinstance(__A ,    __A		):
        snake_case							:		int        =		str(__A		)

    if is_remote_url(__A		):
        # URL, so get it from the cache (downloading if necessary)
        snake_case							:		List[Any]        =		get_from_cache(
            __A ,    cache_dir=__A ,    force_download=__A ,    proxies=__A ,    resume_download=__A ,    user_agent=__A ,    local_files_only=__A ,    )
    elif os.path.exists(__A		):
        # File, and it exists.
        snake_case							:		Tuple        =		url_or_filename
    elif urlparse(__A		).scheme == "":
        # File, but it doesn't exist.
        raise EnvironmentError("""file {} not found""".format(__A		)		)
    else:
        # Something unknown
        raise ValueError("""unable to parse {} as a URL or as a local path""".format(__A		)		)

    if extract_compressed_file:
        if not is_zipfile(__A		) and not tarfile.is_tarfile(__A		):
            return output_path

        # Path where we extract compressed archives
        # We avoid '.' in dir name and add "-extracted" at the end: "./model.zip" => "./model-zip-extracted/"
        snake_case      ,		snake_case							:		Dict        =		os.path.split(__A		)
        snake_case							:		int        =		output_file.replace(""".""" ,    """-"""		) + """-extracted"""
        snake_case							:		Any        =		os.path.join(__A ,    __A		)

        if os.path.isdir(__A		) and os.listdir(__A		) and not force_extract:
            return output_path_extracted

        # Prevent parallel extractions
        snake_case							:		int        =		output_path + """.lock"""
        with FileLock(__A		):
            shutil.rmtree(__A ,    ignore_errors=__A		)
            os.makedirs(__A		)
            if is_zipfile(__A		):
                with ZipFile(__A ,    """r"""		) as zip_file:
                    zip_file.extractall(__A		)
                    zip_file.close()
            elif tarfile.is_tarfile(__A		):
                snake_case							:		Optional[int]        =		tarfile.open(__A		)
                tar_file.extractall(__A		)
                tar_file.close()
            else:
                raise EnvironmentError("""Archive format of {} could not be identified""".format(__A		)		)

        return output_path_extracted

    return output_path







def       lowercase					(	__A :					Optional[int] ,    __A :					str=","		)				->			List[Any]:





    '''simple docstring'''




    assert isinstance(__A ,    __A		)
    if os.path.isfile(__A		):
        with open(__A		) as f:
            snake_case							:		Any        =		eval(f.read()		)
    else:
        snake_case							:		Any        =		requests.get(__A		)
        try:
            snake_case							:		Union[str, Any]        =		requests.json()
        except Exception:
            snake_case							:		Optional[int]        =		req.content.decode()
            assert data is not None, "could not connect"
            try:
                snake_case							:		str        =		eval(__A		)
            except Exception:
                snake_case							:		Optional[Any]        =		data.split("""\n"""		)
        req.close()
    return data







def       lowercase					(	__A :					Dict		)				->			Tuple:





    '''simple docstring'''




    snake_case							:		Union[str, Any]        =		requests.get(__A		)
    snake_case							:		Dict        =		np.array(Image.open(BytesIO(response.content		)		)		)
    return img







def       lowercase					(	__A :					Dict		)				->			Union[str, Any]:





    '''simple docstring'''




    snake_case							:		int        =		url.split("""/"""		)[-1]
    if fn not in os.listdir(os.getcwd()		):
        wget.download(__A		)
    with open(__A ,    """rb"""		) as stream:
        snake_case							:		str        =		pkl.load(__A		)
    snake_case							:		Optional[int]        =		weights.pop("""model"""		)
    snake_case							:		List[Any]        =		{}
    for k, v in model.items():
        snake_case							:		Tuple        =		torch.from_numpy(__A		)
        if "running_var" in k:
            snake_case							:		Optional[int]        =		torch.tensor([0]		)
            snake_case							:		Optional[Any]        =		k.replace("""running_var""" ,    """num_batches_tracked"""		)
            snake_case							:		Any        =		zero
    return new







def       lowercase					(	)				->			List[Any]:





    '''simple docstring'''




    print(f"""{os.path.abspath(os.path.join(__A ,    os.pardir		)		)}/demo.ipynb"""		)







def       lowercase					(	__A :					str ,    __A :					Dict="RGB"		)				->			str:





    '''simple docstring'''




    assert isinstance(__A ,    __A		)
    if os.path.isfile(__A		):
        snake_case							:		List[Any]        =		cva.imread(__A		)
    else:
        snake_case							:		Optional[int]        =		get_image_from_url(__A		)
        assert img is not None, f"""could not connect to: {im}"""
    snake_case							:		Optional[Any]        =		cva.cvtColor(__A ,    cva.COLOR_BGR2RGB		)
    if input_format == "RGB":
        snake_case							:		str        =		img[:, :, ::-1]
    return img







def       lowercase					(	__A :					Union[str, Any] ,    __A :					Union[str, Any]=1		)				->			List[Any]:





    '''simple docstring'''




    return (images[i : i + batch] for i in range(0 ,    len(__A		) ,    __A		))








'''simple docstring'''





# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team.
#
# 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.

# this script dumps information about the environment

import os
import sys

import transformers


__a  			=						"3"

print("Python version:", sys.version)
print("transformers version:", transformers.__version__)

try:
       import torch

       print("Torch version:", torch.__version__)
       print("Cuda available:", torch.cuda.is_available())
       print("Cuda version:", torch.version.cuda)
       print("CuDNN version:", torch.backends.cudnn.version())
       print("Number of GPUs available:", torch.cuda.device_count())
       print("NCCL version:", torch.cuda.nccl.version())
except ImportError:
       print("Torch version:", None)

try:
       import deepspeed

       print("DeepSpeed version:", deepspeed.__version__)
except ImportError:
       print("DeepSpeed version:", None)

try:
       import tensorflow as tf

       print("TensorFlow version:", tf.__version__)
       print("TF GPUs available:", bool(tf.config.list_physical_devices("GPU")))
       print("Number of TF GPUs available:", len(tf.config.list_physical_devices("GPU")))
except ImportError:
       print("TensorFlow version:", None)
