parameters: (initial_probs, target_probs)
return_statement: return ratio_l / max_ratio
docstring: Calculate the per-class acceptance rates.
  
    Args:
      initial_probs: The class probabilities of the data.
      target_probs: The desired class proportion in minibatches.
    Returns:
      A list of the per-class acceptance probabilities.
  
    This method is based on solving the following analysis:
  
    Let F be the probability of a rejection (on any example).
    Let p_i be the proportion of examples in the data in class i (init_probs)
    Let a_i is the rate the rejection sampler should *accept* class i
    Let t_i is the target proportion in the minibatches for class i (target_probs)
  
    ```
    F = sum_i(p_i * (1-a_i))
      = 1 - sum_i(p_i * a_i)     using sum_i(p_i) = 1
    ```
  
    An example with class `i` will be accepted if `k` rejections occur, then an
    example with class `i` is seen by the rejector, and it is accepted. This can
    be written as follows:
  
    ```
    t_i = sum_k=0^inf(F^k * p_i * a_i)
        = p_i * a_j / (1 - F)    using geometric series identity, since 0 <= F < 1
        = p_i * a_i / sum_j(p_j * a_j)        using F from above
    ```
  
    Note that the following constraints hold:
    ```
    0 <= p_i <= 1, sum_i(p_i) = 1
    0 <= a_i <= 1
    0 <= t_i <= 1, sum_i(t_i) = 1
    ```
  
  
    A solution for a_i in terms of the other variabes is the following:
      ```a_i = (t_i / p_i) / max_i[t_i / p_i]```
docstring_summary: Calculate the per-class acceptance rates.
docstring_tokens: Calculate the per - class acceptance rates .
function: def _calculate_acceptance_probs(initial_probs, target_probs):
    """Calculate the per-class acceptance rates.
  
    Args:
      initial_probs: The class probabilities of the data.
      target_probs: The desired class proportion in minibatches.
    Returns:
      A list of the per-class acceptance probabilities.
  
    This method is based on solving the following analysis:
  
    Let F be the probability of a rejection (on any example).
    Let p_i be the proportion of examples in the data in class i (init_probs)
    Let a_i is the rate the rejection sampler should *accept* class i
    Let t_i is the target proportion in the minibatches for class i (target_probs)
  
    ```
    F = sum_i(p_i * (1-a_i))
      = 1 - sum_i(p_i * a_i)     using sum_i(p_i) = 1
    ```
  
    An example with class `i` will be accepted if `k` rejections occur, then an
    example with class `i` is seen by the rejector, and it is accepted. This can
    be written as follows:
  
    ```
    t_i = sum_k=0^inf(F^k * p_i * a_i)
        = p_i * a_j / (1 - F)    using geometric series identity, since 0 <= F < 1
        = p_i * a_i / sum_j(p_j * a_j)        using F from above
    ```
  
    Note that the following constraints hold:
    ```
    0 <= p_i <= 1, sum_i(p_i) = 1
    0 <= a_i <= 1
    0 <= t_i <= 1, sum_i(t_i) = 1
    ```
  
  
    A solution for a_i in terms of the other variabes is the following:
      ```a_i = (t_i / p_i) / max_i[t_i / p_i]```
    """
    # Add tiny to initial_probs to avoid divide by zero.
    denom = (initial_probs + np.finfo(initial_probs.dtype.as_numpy_dtype).tiny)
    ratio_l = target_probs / denom
  
    # Calculate list of acceptance probabilities.
    max_ratio = math_ops.reduce_max(ratio_l)
    return ratio_l / max_ratio
function_tokens: def _calculate_acceptance_probs ( initial_probs , target_probs ) : # Add tiny to initial_probs to avoid divide by zero. denom = ( initial_probs + np . finfo ( initial_probs . dtype . as_numpy_dtype ) . tiny ) ratio_l = target_probs / denom # Calculate list of acceptance probabilities. max_ratio = math_ops . reduce_max ( ratio_l ) return ratio_l / max_ratio