�
%�gL � �. � d dl Z d dlmZmZ d dlZd dlZddlmZ ddl m
Z
ddlmZm
Z
ddlmZmZmZmZmZmZmZ e� � r d dlmc mZ dd
ededefd
�Zddee
deej fd�Zddeee e
f deej fd�Z!dS )� N)�Optional�Union� )�AcceleratorState� )�CUDA_DISTRIBUTED_TYPES)�DistributedType�RNGType)�is_hpu_available�is_mlu_available�is_musa_available�is_npu_available�is_sdaa_available�is_torch_xla_available�is_xpu_availableF�seed�device_specific�
deterministicc � � |r| t � � j z
} t j | � � t j � | � � t j | � � t � � r!t
j � | � � �nt � � r t
j � | � � n�t � � r t
j
� | � � n�t � � r t
j � | � � n{t! � � r t
j � | � � nMt% � � r t
j � | � � nt
j � | � � t+ � � rt- j | � � |rt j d� � dS dS )a�
Helper function for reproducible behavior to set the seed in `random`, `numpy`, `torch`.
Args:
seed (`int`):
The seed to set.
device_specific (`bool`, *optional*, defaults to `False`):
Whether to differ the seed on each device slightly with `self.process_index`.
deterministic (`bool`, *optional*, defaults to `False`):
Whether to use deterministic algorithms where available. Can slow down training.
TN)r �
process_index�randomr �np�torch�manual_seedr �xpu�manual_seed_allr �npur �mlur �sdaar
�musar �hpu�cudar �xm�
set_rng_state�use_deterministic_algorithms)r r r s �g/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/accelerate/utils/random.py�set_seedr'