code: def get_resource_type(resources_dir: str) -> str:
      """
      Detect resource type based on filepath extensions.
      returns:
          `packages`: for .mlpackage resources
          'compiled`: for .mlmodelc resources
      """
      directories = [
          f
          for f in os.listdir(resources_dir)
          if os.path.isdir(os.path.join(resources_dir, f))
      ]
  
      # consider directories ending with extension
      extensions = set(
          [
              os.path.splitext(e)[1]
              for e in directories
              if os.path.splitext(e)[1]
          ]
      )
  
      # if one extension present we may be able to infer sources type
      if len(set(extensions)) == 1:
          extension = extensions.pop()
      else:
          raise ValueError(
              f"Multiple file extensions found at {resources_dir}."
              f"Cannot infer resource type from contents."
          )
  
      if extension == ".mlpackage":
          sources = "packages"
      elif extension == ".mlmodelc":
          sources = "compiled"
      else:
          raise ValueError(
              f"Did not find .mlpackage or .mlmodelc at {resources_dir}"
          )
  
      return sources
  
file_path: ml-stable-diffusion/python_coreml_stable_diffusion/coreml_model.py
imports: import coremltools
  import logging
  import json
  import numpy
  import os
  import time
label_desc: Use image node_id 1 for calling a global function with example usage: get_resource_type(resources_dir) and returns: sources