class_docstr: Represents the WeiGit repo for tracking neural network weights and their versions.
  
  A WeiGit repo is like a git repo. It is a dir, in which a .wgit dir exists to keep
  track of the content.
  
  Args:
      parent_dir (Path, str):
          Parent dir in which to make or to load a .wgit dir.
          Default: "", which means CWD.
      init (bool, optional):
          - If ``True``, initializes a new WeiGit repo in the parent_dir. Initialization
            creates a `.wgit` directory within the <parent_dir>, triggers an initialization.
            of a sha1_store in the ./<parent_dir>/.wgit directory, and makes the
            ./<parent_dir>/.wgit a git repository through git initialization.
          - If ``False``, a new WeiGit repo is not initialized and the existing repo is
            wrapped, populating the `_wgit_parent` and other internal attributes.
          - Default: False
class_docstr_tok: ["Represents","the","WeiGit","repo","for","tracking","neural","network","weights","and","their","versions",".","A","WeiGit","repo","is","like","a","git","repo",".","It","is","a","dir",",","in","which","a",".wgit","dir","exists","to","keep","track","of","the","content",".","Args",":","parent_dir","(","Path",",","str",")",":","Parent","dir","in","which","to","make","or","to","load","a",".wgit","dir",".","Default",":","``","''",",","which","means","CWD",".","init","(","bool",",","optional",")",":","-","If","``","True","``",",","initializes","a","new","WeiGit","repo","in","the","parent_dir",".","Initialization","creates","a","`",".wgit","`","directory","within","the","<","parent_dir",">",",","triggers","an","initialization",".","of","a","sha1_store","in","the",".\/","<","parent_dir",">","\/.wgit","directory",",","and","makes","the",".\/","<","parent_dir",">","\/.wgit","a","git","repository","through","git","initialization",".","-","If","``","False","``",",","a","new","WeiGit","repo","is","not","initialized","and","the","existing","repo","is","wrapped",",","populating","the","`","_wgit_parent","`","and","other","internal","attributes",".","-","Default",":","False"]
code: def __init__(
      self, parent_dir: Union[Path, str] = "", init: bool = False
  ) -> None:
      # Set _wgit_parent.
      self._wgit_parent = Path(
          parent_dir if parent_dir != "" else Path.cwd()
      )
  
      # Set _dot_wgit_dir_path.
      self._dot_wgit_dir_path: Optional[Path] = None
      exists = self._recursive_search_and_may_init_dot_wgit_dir_path(
          self._wgit_parent
      )
  
      if not exists and init:
          # No weigit repo exists and is being initialized with init=True
          # Make .wgit directory, create sha1_store
          self._dot_wgit_dir_path = self._wgit_parent.joinpath(".wgit")
          self._dot_wgit_dir_path.mkdir(parents=False, exist_ok=True)
  
          # Initializing sha1_store only after wgit has been initialized!
          self._sha1_store = SHA1_Store(
              self._dot_wgit_dir_path.joinpath(SHA1_STORE_DIR_NAME),
              init=True,
          )
  
          # Create a git repo for the metadata versioning.
          self._pygit = PyGit(
              self._dot_wgit_dir_path, gitignore=[SHA1_STORE_DIR_NAME]
          )
  
      elif exists:
          # Weigit repo already exists, populate this object.
          assert self._dot_wgit_dir_path is not None
          self._sha1_store = SHA1_Store(
              self._dot_wgit_dir_path.joinpath(SHA1_STORE_DIR_NAME)
          )
          self._pygit = PyGit(self._dot_wgit_dir_path)
  
      else:
          # weigit doesn't exist and is not trying to be initialized (triggers
          # during non-init commands)
          sys.stderr.write("fatal: not a wgit repository!\n")
          sys.exit(1)
  
      # We are done init. Do a check.
      self._sanity_check()
  
imports: import copy
  from dataclasses import dataclass
  from enum import Enum
  import json
  from pathlib import Path
  import sys
  from typing import Any, Dict, List, Optional, Union
  import torch
  from torch import Tensor
  from .pygit import PyGit
  from .sha1_store import SHA1_Store
label_desc: Use image node_id 1 to create a new Repo object  with example: obj = Repo(parent_dir, init)