class_docstr: Base class for Autoencoder based models.
  
  Args:
      model_config (BaseAEConfig): An instance of BaseAEConfig in which any model's parameters is
          made available.
  
      encoder (BaseEncoder): An instance of BaseEncoder (inheriting from `torch.nn.Module` which
          plays the role of encoder. This argument allows you to use your own neural networks
          architectures if desired. If None is provided, a simple Multi Layer Preception
          (https://en.wikipedia.org/wiki/Multilayer_perceptron) is used. Default: None.
  
      decoder (BaseDecoder): An instance of BaseDecoder (inheriting from `torch.nn.Module` which
          plays the role of decoder. This argument allows you to use your own neural networks
          architectures if desired. If None is provided, a simple Multi Layer Preception
          (https://en.wikipedia.org/wiki/Multilayer_perceptron) is used. Default: None.
  
  .. note::
      For high dimensional data we advice you to provide you own network architectures. With the
      provided MLP you may end up with a ``MemoryError``.
class_docstr_tok: ["Base","class","for","Autoencoder","based","models",".","Args",":","model_config","(","BaseAEConfig",")",":","An","instance","of","BaseAEConfig","in","which","any","model","'s","parameters","is","made","available",".","encoder","(","BaseEncoder",")",":","An","instance","of","BaseEncoder","(","inheriting","from","`","torch.nn.Module","`","which","plays","the","role","of","encoder",".","This","argument","allows","you","to","use","your","own","neural","networks","architectures","if","desired",".","If","None","is","provided",",","a","simple","Multi","Layer","Preception","(","https",":","\/\/en.wikipedia.org\/wiki\/Multilayer_perceptron",")","is","used",".","Default",":","None",".","decoder","(","BaseDecoder",")",":","An","instance","of","BaseDecoder","(","inheriting","from","`","torch.nn.Module","`","which","plays","the","role","of","decoder",".","This","argument","allows","you","to","use","your","own","neural","networks","architectures","if","desired",".","If","None","is","provided",",","a","simple","Multi","Layer","Preception","(","https",":","\/\/en.wikipedia.org\/wiki\/Multilayer_perceptron",")","is","used",".","Default",":","None",".","..","note",":",":","For","high","dimensional","data","we","advice","you","to","provide","you","own","network","architectures",".","With","the","provided","MLP","you","may","end","up","with","a","``","MemoryError","``","."]
docstr: Method allowing to save your model directly on the Hugging Face hub.
  You will need to have the `huggingface_hub` package installed and a valid Hugging Face
  account. You can install the package using
  
  .. code-block:: bash
  
      python -m pip install huggingface_hub
  
  end then login using
  
  .. code-block:: bash
  
      huggingface-cli login
  
  Args:
      hf_hub_path (str): path to your repo on the Hugging Face hub.
docstr_tok: ["Method","allowing","to","save","your","model","directly","on","the","Hugging","Face","hub",".","You","will","need","to","have","the","`","huggingface_hub","`","package","installed","and","a","valid","Hugging","Face","account",".","You","can","install","the","package","using","..","code-block",":",":","bash","python","-m","pip","install","huggingface_hub","end","then","login","using","..","code-block",":",":","bash","huggingface-cli","login","Args",":","hf_hub_path","(","str",")",":","path","to","your","repo","on","the","Hugging","Face","hub","."]
code: def push_to_hf_hub(self, hf_hub_path: str):  # pragma: no cover
      """Method allowing to save your model directly on the Hugging Face hub.
      You will need to have the `huggingface_hub` package installed and a valid Hugging Face
      account. You can install the package using
  
      .. code-block:: bash
  
          python -m pip install huggingface_hub
  
      end then login using
  
      .. code-block:: bash
  
          huggingface-cli login
  
      Args:
          hf_hub_path (str): path to your repo on the Hugging Face hub.
      """
      if not hf_hub_is_available():
          raise ModuleNotFoundError(
              "`huggingface_hub` package must be installed to push your model to the HF hub. "
              "Run `python -m pip install huggingface_hub` and log in to your account with "
              "`huggingface-cli login`."
          )
  
      else:
          from huggingface_hub import CommitOperationAdd, HfApi
  
      logger.info(
          f"Uploading {self.model_name} model to {hf_hub_path} repo in HF hub..."
      )
  
      tempdir = tempfile.mkdtemp()
  
      self.save(tempdir)
  
      model_files = os.listdir(tempdir)
  
      api = HfApi()
      hf_operations = []
  
      for file in model_files:
          hf_operations.append(
              CommitOperationAdd(
                  path_in_repo=file,
                  path_or_fileobj=f"{str(os.path.join(tempdir, file))}",
              )
          )
  
      with open(os.path.join(tempdir, "model_card.md"), "w") as f:
          f.write(model_card_template)
  
      hf_operations.append(
          CommitOperationAdd(
              path_in_repo="README.md",
              path_or_fileobj=os.path.join(tempdir, "model_card.md"),
          )
      )
  
      try:
          api.create_commit(
              commit_message=f"Uploading {self.model_name} in {hf_hub_path}",
              repo_id=hf_hub_path,
              operations=hf_operations,
          )
          logger.info(
              f"Successfully uploaded {self.model_name} to {hf_hub_path} repo in HF hub!"
          )
  
      except:
          from huggingface_hub import create_repo
  
          repo_name = os.path.basename(os.path.normpath(hf_hub_path))
          logger.info(
              f"Creating {repo_name} in the HF hub since it does not exist..."
          )
          create_repo(repo_id=repo_name)
          logger.info(
              f"Successfully created {repo_name} in the HF hub!"
          )
  
          api.create_commit(
              commit_message=f"Uploading {self.model_name} in {hf_hub_path}",
              repo_id=hf_hub_path,
              operations=hf_operations,
          )
  
      shutil.rmtree(tempdir)
  
imports: import inspect
  import logging
  import os
  import shutil
  import sys
  import tempfile
  import warnings
  from copy import deepcopy
  from http.cookiejar import LoadError
  from typing import Optional
  import cloudpickle
  import torch
  import torch.nn
  from ...customexception import BadInheritanceError
  from ...data.datasets import BaseDataset, DatasetOutput
  from ..auto_model import AutoConfig
  from ..nn import BaseDecoder, BaseEncoder
  from ..nn.default_architectures import Decoder_AE_MLP
  from .base_config import BaseAEConfig, EnvironmentConfig
  from .base_utils import CPU_Unpickler, ModelOutput, hf_hub_is_available, model_card_template
label_desc: Use image node_id 9 for calling the BaseAE obj's underlying member method code with example usage: obj.push_to_hf_hub(hf_hub_path) without return types