<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/transform/blob/v1.21.0/tensorflow_transform/analyzers.py#L836-L888) |

Computes the count of each element of a `Tensor`.

    tft.count_per_key(
        key: common_types.TensorType,
        key_vocabulary_filename: Optional[str] = None,
        name: Optional[str] = None
    )

<br />

<br />

<br />

| ## Args ||
|---|---|

<br />

*** ** * ** ***

key: A `Tensor`, `SparseTensor`, or `RaggedTensor` of dtype tf.string or
tf.int.
key_vocabulary_filename: (Optional) The file name for the key-output mapping
file. If None and key are provided, this combiner assumes the keys fit in
memory and will not store the result in a file. If empty string, a file
name will be chosen based on the current scope. If not an empty string,
should be unique within a given preprocessing function.
name: (Optional) A name for this operation.

<br />

<br />

<br />

| ## Returns ||
|---|---|

<br />

*** ** * ** ***

Either:
(A) Two `Tensor`s: one the key vocab with dtype of input;
the other the count for each key, dtype tf.int64. (if
key_vocabulary_filename is None).
(B) The filename where the key-value mapping is stored (if
key_vocabulary_filename is not None).

<br />

<br />

<br />

| ## Raises ||
|---|---|

<br />

*** ** * ** ***

TypeError: If the type of `x` is not supported.