def empirical_cdfs(samples, positions, continuity='<STR_LIT:right>',<EOL>dtype=tf.float32, name=None):
if continuity not in ['<STR_LIT:left>', '<STR_LIT:right>']:<EOL><INDENT>msg = '<STR_LIT>'.format(<EOL>continuity)<EOL>raise ValueError(msg)<EOL><DEDENT>with tf.compat.v1.name_scope(name, '<STR_LIT>', [samples, positions]):<EOL><INDENT>n = tf.cast(tf.shape(input=samples)[-<NUM_LIT:1>], dtype=dtype)<EOL>indexes = tf.searchsorted(<EOL>sorted_sequence=samples, values=positions, side=continuity)<EOL>return tf.cast(indexes, dtype=dtype) / n<EOL><DEDENT>
Evaluates the empirical CDF of a batch of samples at a batch of positions.

    If elements of `positions` might be exactly equal to elements of `samples`
    (e.g., if the underlying distribution of interest is discrete), there is a
    difference between the conventional, right-continuous CDF (Pr[X <= x]) and a
    left-continuous variant (Pr[X < x]).  The latter can be accessed by setting
    `continuity='left'`.  The difference between the right-continuous and
    left-continuous CDFs is the empirical pmf at each point, i.e., how many times
    each element of `positions` occurs in its batch of `samples`.

    Note: Returns results parallel to `positions`, i.e., the values of the
    empirical CDF at those points.

    Note: The sample dimension is _last_, and the samples must be _sorted_ within
    each batch.

    Args:
      samples: Tensor of shape `batch + [num_samples]` of samples.  The samples
        must be in ascending order within each batch member.
      positions: Tensor of shape `batch + [m]` of positions where to evaluate the
        CDFs.  The positions need not be sorted.
      continuity: Whether to return a conventional, right-continuous CDF
        (`continuity = 'right'`, default) or a left-continuous CDF (`continuity =
        'left'`).  The value at each point `x` will be `F_n(X <= x)` or
        `F_n(X < x)`, respectively.
      dtype: dtype at which to evaluate the desired empirical CDFs.
      name: A name for this operation (optional).

    Returns:
      cdf: Tensor parallel to `positions`.  For each x in `positions`, gives the
        (right- or left-continuous, per the `continuity` argument) cdf at that
        position.  If `positions` contains duplicates, `cdf` will give each the
        same value.