def hash_strings(
    strings: common_types.ConsistentTensorType,
    hash_buckets: int,
    key: Optional[Iterable[int]] = None,
    name: Optional[str] = None) -> common_types.ConsistentTensorType:
  """Hash strings into buckets.

  Args:
    strings: a `Tensor`, `SparseTensor`, or `RaggedTensor` of dtype `tf.string`.
    hash_buckets: the number of hash buckets.
    key: optional. An array of two Python `uint64`. If passed, output will be a
      deterministic function of `strings` and `key`. Note that hashing will be
      slower if this value is specified.
    name: (Optional) A name for this operation.

  Returns:
    A `Tensor`, `SparseTensor`, or `RaggedTensor` of dtype `tf.int64` with the
    same shape as
    the input `strings`.

  Raises:
    TypeError: if `strings` is not a `Tensor`, `SparseTensor`, or `RaggedTensor`
    of dtype `tf.string`.
  """
  if (not isinstance(strings, (tf.Tensor, tf.SparseTensor, tf.RaggedTensor)) or
      strings.dtype != tf.string):
    raise TypeError(
        'Input to hash_strings must be a `Tensor`, `SparseTensor`, or '
        f'`RaggedTensor` of dtype string; got {strings.dtype}')
  if isinstance(strings, tf.Tensor):
    if name is None:
      name = 'hash_strings'
    if key is None:
      return tf.strings.to_hash_bucket_fast(strings, hash_buckets, name=name)
    return tf.strings.to_hash_bucket_strong(
        strings, hash_buckets, key, name=name)
  else:
    compose_result_fn = _make_composite_tensor_wrapper_if_composite(strings)
    values = tf_utils.get_values(strings)
    return compose_result_fn(hash_strings(values, hash_buckets, key))
Hash strings into buckets.

  Args:
    strings: a `Tensor`, `SparseTensor`, or `RaggedTensor` of dtype `tf.string`.
    hash_buckets: the number of hash buckets.
    key: optional. An array of two Python `uint64`. If passed, output will be a
      deterministic function of `strings` and `key`. Note that hashing will be
      slower if this value is specified.
    name: (Optional) A name for this operation.

  Returns:
    A `Tensor`, `SparseTensor`, or `RaggedTensor` of dtype `tf.int64` with the
    same shape as
    the input `strings`.

  Raises:
    TypeError: if `strings` is not a `Tensor`, `SparseTensor`, or `RaggedTensor`
    of dtype `tf.string`.
  
tensorflow_transform/mappers.py