code: def perform_integrity_check(buffer: bytes, metadata_path: Path):
      """Validates the integrity of bytes by comparing the hash value"""
      secret_key = os.environ.get("SAGEMAKER_SERVE_SECRET_KEY")
      actual_hash_value = compute_hash(
          buffer=buffer, secret_key=secret_key
      )
  
      if not Path.exists(metadata_path):
          raise ValueError("Path to metadata.json does not exist")
  
      with open(str(metadata_path), "rb") as md:
          expected_hash_value = _MetaData.from_json(
              md.read()
          ).sha256_hash
  
      if not hmac.compare_digest(
          expected_hash_value, actual_hash_value
      ):
          raise ValueError(
              "Integrity check for the serialized function or data failed."
          )
  
file_path: sagemaker-python-sdk/src/sagemaker/serve/validations/check_integrity.py
imports: from __future__ import absolute_import
  import secrets
  import hmac
  import hashlib
  import os
  from pathlib import Path
  from sagemaker.remote_function.core.serialization import _MetaData
label_desc: Use image node_id 3 for calling a global function with example usage: perform_integrity_check(buffer, metadata_path) without return types