code: def _to_bytes(data: HashKey) -> bytes:
      """Converts the key to bytes."""
      if isinstance(data, bytes):
          return data
      elif isinstance(data, str):
          # For windows compatibility, we normalize the key in case a
          # filepath is passed as key ('path\\to\\file' -> 'path/to/file')
          data = data.replace("\\", "/")
      elif isinstance(data, int):
          data = str(data)
      elif (
          isinstance(data, np.ndarray) and data.size == 1
      ):  # Singleton array
          return _to_bytes(data.item())
      else:
          raise TypeError(f"Invalid key type: {data!r} ({type(data)})")
      return data.encode("utf-8")
  
imports: import hashlib
  from typing import Union
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: _to_bytes(data) and returns: data, data, _to_bytes