o
    2hD                     @   s   d dl mZ d dlmZ edd%ddZed	d&ddZedd%ddZedd&ddZedd%ddZedd'ddZ	edd(ddZ
edd'ddZedd'd d!Zed"d'd#d$ZdS ))    )backend)keras_exportzkeras.random.normal              ?Nc                 C      t jj| ||||dS )a  Draw random samples from a normal (Gaussian) distribution.

    Args:
        shape: The shape of the random values to generate.
        mean: Float, defaults to 0. Mean of the random values to generate.
        stddev: Float, defaults to 1. Standard deviation of the random values
            to generate.
        dtype: Optional dtype of the tensor. Only floating point types are
            supported. If not specified, `keras.config.floatx()` is used,
            which defaults to `float32` unless you configured it otherwise (via
            `keras.config.set_floatx(float_dtype)`).
        seed: Optional Python integer or instance of
           `keras.random.SeedGenerator`.
            By default, the `seed` argument is `None`, and an internal global
            `keras.random.SeedGenerator` is used. The `seed` argument can be
            used to ensure deterministic (repeatable) random number generation.
            Note that passing an integer as the `seed` value will produce the
            same random values for each call. To generate different random
            values for repeated calls, an instance of
            `keras.random.SeedGenerator` must be provided as the `seed` value.
            Remark concerning the JAX backend: When tracing functions with the
            JAX backend the global `keras.random.SeedGenerator` is not
            supported. Therefore, during tracing the default value `seed=None`
            will produce an error, and a `seed` argument must be provided.
    meanstddevdtypeseed)r   randomnormalshaper   r	   r
   r    r   R/var/www/html/chatgem/venv/lib/python3.10/site-packages/keras/src/random/random.pyr      s   
r   zkeras.random.categoricalint32c                 C   s>   t t| j}t|dkrtd|  tjj| |||dS )a  Draws samples from a categorical distribution.

    This function takes as input `logits`, a 2-D input tensor with shape
    (batch_size, num_classes). Each row of the input represents a categorical
    distribution, with each column index containing the log-probability for a
    given class.

    The function will output a 2-D tensor with shape (batch_size, num_samples),
    where each row contains samples from the corresponding row in `logits`.
    Each column index contains an independent samples drawn from the input
    distribution.

    Args:
        logits: 2-D Tensor with shape (batch_size, num_classes). Each row
            should define a categorical distribution with the unnormalized
            log-probabilities for all classes.
        num_samples: Int, the number of independent samples to draw for each
            row of the input. This will be the second dimension of the output
            tensor's shape.
        dtype: Optional dtype of the output tensor.
        seed: Optional Python integer or instance of
           `keras.random.SeedGenerator`.
            By default, the `seed` argument is `None`, and an internal global
            `keras.random.SeedGenerator` is used. The `seed` argument can be
            used to ensure deterministic (repeatable) random number generation.
            Note that passing an integer as the `seed` value will produce the
            same random values for each call. To generate different random
            values for repeated calls, an instance of
            `keras.random.SeedGenerator` must be provided as the `seed` value.
            Remark concerning the JAX backend: When tracing functions with the
            JAX backend the global `keras.random.SeedGenerator` is not
            supported. Therefore, during tracing the default value seed=None
            will produce an error, and a `seed` argument must be provided.

    Returns:
        A 2-D tensor with (batch_size, num_samples).
       zW`logits` should be a 2-D tensor with shape [batch_size, num_classes]. Received: logits=)r
   r   )listr   convert_to_tensorr   len
ValueErrorr   categorical)logitsnum_samplesr
   r   logits_shaper   r   r   r   %   s   'r   zkeras.random.uniformc                 C   4   |rt |std| dt jj| ||||dS )a  Draw samples from a uniform distribution.

    The generated values follow a uniform distribution in the range
    `[minval, maxval)`. The lower bound `minval` is included in the range,
    while the upper bound `maxval` is excluded.

    `dtype` must be a floating point type, the default range is `[0, 1)`.

    Args:
        shape: The shape of the random values to generate.
        minval: Float, defaults to 0. Lower bound of the range of
            random values to generate (inclusive).
        maxval: Float, defaults to 1. Upper bound of the range of
            random values to generate (exclusive).
        dtype: Optional dtype of the tensor. Only floating point types are
            supported. If not specified, `keras.config.floatx()` is used,
            which defaults to `float32` unless you configured it otherwise (via
            `keras.config.set_floatx(float_dtype)`)
        seed: Optional Python integer or instance of
           `keras.random.SeedGenerator`.
            By default, the `seed` argument is `None`, and an internal global
            `keras.random.SeedGenerator` is used. The `seed` argument can be
            used to ensure deterministic (repeatable) random number generation.
            Note that passing an integer as the `seed` value will produce the
            same random values for each call. To generate different random
            values for repeated calls, an instance of
            `keras.random.SeedGenerator` must be provided as the `seed` value.
            Remark concerning the JAX backend: When tracing functions with the
            JAX backend the global `keras.random.SeedGenerator` is not
            supported. Therefore, during tracing the default value seed=None
            will produce an error, and a `seed` argument must be provided.
    zJ`keras.random.uniform` requires a floating point `dtype`. Received: dtype= minvalmaxvalr
   r   )r   is_float_dtyper   r   uniformr   r   r    r
   r   r   r   r   r"   W      "
r"   zkeras.random.randintc                 C   r   )a  Draw random integers from a uniform distribution.

    The generated values follow a uniform distribution in the range
    `[minval, maxval)`. The lower bound `minval` is included in the range,
    while the upper bound `maxval` is excluded.

    `dtype` must be an integer type.

    Args:
        shape: The shape of the random values to generate.
        minval: Float, defaults to 0. Lower bound of the range of
            random values to generate (inclusive).
        maxval: Float, defaults to 1. Upper bound of the range of
            random values to generate (exclusive).
        dtype: Optional dtype of the tensor. Only integer types are
            supported. If not specified, `keras.config.floatx()` is used,
            which defaults to `float32` unless you configured it otherwise (via
            `keras.config.set_floatx(float_dtype)`)
        seed: Optional Python integer or instance of
           `keras.random.SeedGenerator`.
            By default, the `seed` argument is `None`, and an internal global
            `keras.random.SeedGenerator` is used. The `seed` argument can be
            used to ensure deterministic (repeatable) random number generation.
            Note that passing an integer as the `seed` value will produce the
            same random values for each call. To generate different random
            values for repeated calls, an instance of
            `keras.random.SeedGenerator` must be provided as the `seed` value.
            Remark concerning the JAX backend: When tracing functions with the
            JAX backend the global `keras.random.SeedGenerator` is not
            supported. Therefore, during tracing the default value seed=None
            will produce an error, and a `seed` argument must be provided.
    zD`keras.random.randint` requires an integer `dtype`. Received: dtype=r   r   )r   is_int_dtyper   r   randintr#   r   r   r   r&      r$   r&   zkeras.random.truncated_normalc                 C   r   )a  Draw samples from a truncated normal distribution.

    The values are drawn from a normal distribution with specified mean and
    standard deviation, discarding and re-drawing any samples that are more
    than two standard deviations from the mean.

    Args:
        shape: The shape of the random values to generate.
        mean: Float, defaults to 0. Mean of the random values to generate.
        stddev: Float, defaults to 1. Standard deviation of the random values
            to generate.
        dtype: Optional dtype of the tensor. Only floating point types are
            supported. If not specified, `keras.config.floatx()` is used,
            which defaults to `float32` unless you configured it otherwise (via
            `keras.config.set_floatx(float_dtype)`)
        seed: Optional Python integer or instance of
           `keras.random.SeedGenerator`.
            By default, the `seed` argument is `None`, and an internal global
            `keras.random.SeedGenerator` is used. The `seed` argument can be
            used to ensure deterministic (repeatable) random number generation.
            Note that passing an integer as the `seed` value will produce the
            same random values for each call. To generate different random
            values for repeated calls, an instance of
            `keras.random.SeedGenerator` must be provided as the `seed` value.
            Remark concerning the JAX backend: When tracing functions with the
            JAX backend the global `keras.random.SeedGenerator` is not
            supported. Therefore, during tracing the default value seed=None
            will produce an error, and a `seed` argument must be provided.
    r   )r   r   truncated_normalr   r   r   r   r'         
r'   zkeras.random.dropoutc                 C      t jj| |||dS )N)noise_shaper   )r   r   dropout)inputsrater*   r   r   r   r   r+      s   r+   zkeras.random.shufflec                 C   s   t jj| ||dS )ap  Shuffle the elements of a tensor uniformly at random along an axis.

    Args:
        x: The tensor to be shuffled.
        axis: An integer specifying the axis along which to shuffle. Defaults to
            `0`.
        seed: Optional Python integer or instance of
           `keras.random.SeedGenerator`.
            By default, the `seed` argument is `None`, and an internal global
            `keras.random.SeedGenerator` is used. The `seed` argument can be
            used to ensure deterministic (repeatable) random number generation.
            Note that passing an integer as the `seed` value will produce the
            same random values for each call. To generate different random
            values for repeated calls, an instance of
            `keras.random.SeedGenerator` must be provided as the `seed` value.
            Remark concerning the JAX backend: When tracing functions with the
            JAX backend the global `keras.random.SeedGenerator` is not
            supported. Therefore, during tracing the default value seed=None
            will produce an error, and a `seed` argument must be provided.
    )axisr   )r   r   shuffle)xr.   r   r   r   r   r/      s   r/   zkeras.random.gammac                 C   r)   )ac  Draw random samples from the Gamma distribution.

    Args:
        shape: The shape of the random values to generate.
        alpha: Float, the parameter of the distribution.
        dtype: Optional dtype of the tensor. Only floating point types are
            supported. If not specified, `keras.config.floatx()` is used,
            which defaults to `float32` unless you configured it otherwise (via
            `keras.config.set_floatx(float_dtype)`).
        seed: Optional Python integer or instance of
           `keras.random.SeedGenerator`.
            By default, the `seed` argument is `None`, and an internal global
            `keras.random.SeedGenerator` is used. The `seed` argument can be
            used to ensure deterministic (repeatable) random number generation.
            Note that passing an integer as the `seed` value will produce the
            same random values for each call. To generate different random
            values for repeated calls, an instance of
            `keras.random.SeedGenerator` must be provided as the `seed` value.
            Remark concerning the JAX backend: When tracing functions with the
            JAX backend the global `keras.random.SeedGenerator` is not
            supported. Therefore, during tracing the default value seed=None
            will produce an error, and a `seed` argument must be provided.
    )alphar
   r   )r   r   gamma)r   r1   r
   r   r   r   r   r2      s   r2   zkeras.random.binomialc                 C   r   )a  Draw samples from a Binomial distribution.

    The values are drawn from a Binomial distribution with
    specified trial count and probability of success.

    Args:
        shape: The shape of the random values to generate.
        counts: A number or array of numbers representing the
            number of trials. It must be broadcastable with `probabilities`.
        probabilities: A float or array of floats representing the
            probability of success of an individual event.
            It must be broadcastable with `counts`.
        dtype: Optional dtype of the tensor. Only floating point types are
            supported. If not specified, `keras.config.floatx()` is used,
            which defaults to `float32` unless you configured it otherwise (via
            `keras.config.set_floatx(float_dtype)`).
        seed: Optional Python integer or instance of
           `keras.random.SeedGenerator`.
            By default, the `seed` argument is `None`, and an internal global
            `keras.random.SeedGenerator` is used. The `seed` argument can be
            used to ensure deterministic (repeatable) random number generation.
            Note that passing an integer as the `seed` value will produce the
            same random values for each call. To generate different random
            values for repeated calls, an instance of
            `keras.random.SeedGenerator` must be provided as the `seed` value.
            Remark concerning the JAX backend: When tracing functions with the
            JAX backend the global `keras.random.SeedGenerator` is not
            supported. Therefore, during tracing the default value seed=None
            will produce an error, and a `seed` argument must be provided.
    )countsprobabilitiesr
   r   )r   r   binomial)r   r3   r4   r
   r   r   r   r   r5     s    r5   zkeras.random.betac                 C   r   )a  Draw samples from a Beta distribution.

    The values are drawn from a Beta distribution parametrized
    by alpha and beta.

    Args:
        shape: The shape of the random values to generate.
        alpha: Float or an array of floats representing the first
            parameter alpha. Must be broadcastable with `beta` and `shape`.
        beta: Float or an array of floats representing the second
            parameter beta. Must be broadcastable with `alpha` and `shape`.
        dtype: Optional dtype of the tensor. Only floating point types are
            supported. If not specified, `keras.config.floatx()` is used,
            which defaults to `float32` unless you configured it otherwise (via
            `keras.config.set_floatx(float_dtype)`).
        seed: Optional Python integer or instance of
           `keras.random.SeedGenerator`.
            By default, the `seed` argument is `None`, and an internal global
            `keras.random.SeedGenerator` is used. The `seed` argument can be
            used to ensure deterministic (repeatable) random number generation.
            Note that passing an integer as the `seed` value will produce the
            same random values for each call. To generate different random
            values for repeated calls, an instance of
            `keras.random.SeedGenerator` must be provided as the `seed` value.
            Remark concerning the JAX backend: When tracing functions with the
            JAX backend the global `keras.random.SeedGenerator` is not
            supported. Therefore, during tracing the default value seed=None
            will produce an error, and a `seed` argument must be provided.
    r   r1   betar
   r   )r   r   r7   r6   r   r   r   r7   8  r(   r7   )r   r   NN)r   N)NN)r   N)	keras.srcr   keras.src.api_exportr   r   r   r"   r&   r'   r+   r/   r2   r5   r7   r   r   r   r   <module>   s,    1++#(