code: def _hash_categorical(
      cat: Categorical, encoding: str, hash_key: str
  ) -> npt.NDArray[np.uint64]:
      """
      Hash a Categorical by hashing its categories, and then mapping the codes
      to the hashes
  
      Parameters
      ----------
      cat : Categorical
      encoding : str
      hash_key : str
  
      Returns
      -------
      ndarray[np.uint64] of hashed values, same size as len(c)
      """
      # Convert ExtensionArrays to ndarrays
      values = np.asarray(cat.categories._values)
      hashed = hash_array(values, encoding, hash_key, categorize=False)
  
      # we have uint64, as we don't directly support missing values
      # we don't want to use take_nd which will coerce to float
      # instead, directly construct the result with a
      # max(np.uint64) as the missing value indicator
      #
      # TODO: GH 15362
  
      mask = cat.isna()
      if len(hashed):
          result = hashed.take(cat.codes)
      else:
          result = np.zeros(len(mask), dtype="uint64")
  
      if mask.any():
          result[mask] = lib.u8max
  
      return result
  
file_path: catboost/contrib/python/pandas/py3/pandas/core/util/hashing.py
imports: from __future__ import annotations
  import itertools
  from typing import TYPE_CHECKING, Hashable, Iterable, Iterator, cast
  import numpy
  from pandas._libs import lib
  from pandas._libs.hashing import hash_object_array
  from pandas._typing import ArrayLike, npt
  from pandas.core.dtypes.common import is_categorical_dtype, is_list_like
  from pandas.core.dtypes.generic import ABCDataFrame, ABCExtensionArray, ABCIndex, ABCMultiIndex, ABCSeries
label_desc: Use image node_id 4 for calling a global function with example usage: _hash_categorical(cat, encoding, hash_key) and returns: result