code: def validate_allowed_granularity_values(instance, attribute, value):
      if value is None:
          return
      allowed_values = [
          "per_scalar",
          "per_kernel",
          "per_channel",
          "per_layer",
      ]
      if value not in allowed_values:
          raise ValueError(
              f"Allowed values for granularity are: {', '.join(allowed_values)}. "
              f"Received: {value}"
          )
  
file_path: coremltools/coremltools/optimize/torch/pruning/_utils.py
imports: import logging
  from typing import List
  from typing import Optional
  from typing import Tuple
  from typing import cast
  import numpy
  import torch
label_desc: Use image node_id 10 for calling a global function with example usage: validate_allowed_granularity_values(instance, attribute, value) without return types