
    IThj                         S SK r S SKrS SKJr  S SKJrJr  S SKJrJ	r	J
r
JrJr  \r\r\
S   r\ " S S5      5       r\ " S S	5      5       r\ " S
 S5      5       rg)    N)defaultdict)	dataclassfield)DictListLiteralOptionalTuple)
F64F32F16BF16I64I32I16I8U8BOOLc                   h    \ rS rSr% Sr\\S'   \\   \S'   \	\\4   \S'   \
" SS9r\\S'   SS
 jrSrg	)
TensorInfo   a  Information about a tensor.

For more details regarding the safetensors format, check out https://huggingface.co/docs/safetensors/index#format.

Attributes:
    dtype (`str`):
        The data type of the tensor ("F64", "F32", "F16", "BF16", "I64", "I32", "I16", "I8", "U8", "BOOL").
    shape (`List[int]`):
        The shape of the tensor.
    data_offsets (`Tuple[int, int]`):
        The offsets of the data in the file as a tuple `[BEGIN, END]`.
    parameter_count (`int`):
        The number of parameters in the tensor.
dtypeshapedata_offsetsFinitparameter_countNc                      [         R                  " [        R                  U R                  5      U l        g ! [         a
    SU l         g f = f)N   )	functoolsreduceoperatormulr   r   	TypeError)selfs    Z/var/www/auris/envauris/lib/python3.13/site-packages/huggingface_hub/utils/_safetensors.py__post_init__TensorInfo.__post_init__#   s;    	%#,#3#3HLL$**#MD  	%#$D 	%s   47 A
Ar   returnN)__name__
__module____qualname____firstlineno____doc__DTYPE_T__annotations__r   intr
   r   r   r'   __static_attributes__     r&   r   r      s:     N9S/! e,OS,%r6   r   c                   l    \ rS rSr% Sr\\\4   \S'   \\\	4   \S'   \
" SS9r\\\4   \S'   SS	 jrS
rg)SafetensorsFileMetadata+   a  Metadata for a Safetensors file hosted on the Hub.

This class is returned by [`parse_safetensors_file_metadata`].

For more details regarding the safetensors format, check out https://huggingface.co/docs/safetensors/index#format.

Attributes:
    metadata (`Dict`):
        The metadata contained in the file.
    tensors (`Dict[str, TensorInfo]`):
        A map of all tensors. Keys are tensor names and values are information about the corresponding tensor, as a
        [`TensorInfo`] object.
    parameter_count (`Dict[str, int]`):
        A map of the number of parameters per data type. Keys are data types and values are the number of parameters
        of that data type.
metadatatensorsFr   r   Nc                     [        [        5      nU R                  R                  5        H#  nXR                  ==   UR
                  -  ss'   M%     [        U5      U l        g N)r   r3   r;   valuesr   r   dict)r%   r   tensors      r&   r'   %SafetensorsFileMetadata.__post_init__B   sH    .9#.>ll))+FLL)V-C-CC) ,#O4r6   r)   r*   )r,   r-   r.   r/   r0   r   strr2   TENSOR_NAME_Tr   r   r   r1   r3   r'   r4   r5   r6   r&   r8   r8   +   sD    " 38n-+,,*/U*;OT'3,';5r6   r8   c                       \ rS rSr% Sr\\   \S'   \\S'   \\	\
4   \S'   \\
\4   \S'   \" SS9r\\\4   \S	'   SS jrSrg
)SafetensorsRepoMetadataI   a  Metadata for a Safetensors repo.

A repo is considered to be a Safetensors repo if it contains either a 'model.safetensors' weight file (non-shared
model) or a 'model.safetensors.index.json' index file (sharded model) at its root.

This class is returned by [`get_safetensors_metadata`].

For more details regarding the safetensors format, check out https://huggingface.co/docs/safetensors/index#format.

Attributes:
    metadata (`Dict`, *optional*):
        The metadata contained in the 'model.safetensors.index.json' file, if it exists. Only populated for sharded
        models.
    sharded (`bool`):
        Whether the repo contains a sharded model or not.
    weight_map (`Dict[str, str]`):
        A map of all weights. Keys are tensor names and values are filenames of the files containing the tensors.
    files_metadata (`Dict[str, SafetensorsFileMetadata]`):
        A map of all files metadata. Keys are filenames and values are the metadata of the corresponding file, as
        a [`SafetensorsFileMetadata`] object.
    parameter_count (`Dict[str, int]`):
        A map of the number of parameters per data type. Keys are data types and values are the number of parameters
        of that data type.
r:   sharded
weight_mapfiles_metadataFr   r   Nc                     [        [        5      nU R                  R                  5        H2  nUR                  R                  5        H  u  p4X==   U-  ss'   M     M4     [        U5      U l        g r=   )r   r3   rI   r>   r   itemsr?   )r%   r   file_metadatar   nb_parameters_s        r&   r'   %SafetensorsRepoMetadata.__post_init__j   s_    .9#.>!00779M)6)F)F)L)L)N%&.8& *O :  $O4r6   r)   r*   )r,   r-   r.   r/   r0   r	   r   r2   boolrC   
FILENAME_Tr8   r   r   r1   r3   r'   r4   r5   r6   r&   rE   rE   I   sV    2 tnM]J.//%<<==*/U*;OT'3,';5r6   rE   )r    r"   collectionsr   dataclassesr   r   typingr   r   r   r	   r
   rB   rP   rC   r1   r   r8   rE   r5   r6   r&   <module>rT      sy      # ( 7 7 

V
W % % %: 5 5 5: %5 %5 %5r6   