code: def _processor(
      instance_type,
      available_processors,
      serverless_inference_config=None,
  ):
      """Returns the processor type for the given instance type."""
      if not available_processors:
          logger.info(
              "Ignoring unnecessary instance type: %s.", instance_type
          )
          return None
  
      if len(available_processors) == 1 and not instance_type:
          logger.info(
              "Defaulting to only supported image scope: %s.",
              available_processors[0],
          )
          return available_processors[0]
  
      if serverless_inference_config is not None:
          logger.info(
              "Defaulting to CPU type when using serverless inference"
          )
          return "cpu"
  
      if not instance_type:
          raise ValueError(
              "Empty SageMaker instance type. For options, see: "
              "https://aws.amazon.com/sagemaker/pricing/instance-types"
          )
  
      if instance_type.startswith("local"):
          processor = "cpu" if instance_type == "local" else "gpu"
      elif instance_type.startswith("neuron"):
          processor = "neuron"
      else:
          # looks for either "ml.<family>.<size>" or "ml_<family>"
          family = utils.get_instance_type_family(instance_type)
          if family:
              # For some frameworks, we have optimized images for specific families, e.g c5 or p3.
              # In those cases, we use the family name in the image tag. In other cases, we use
              # 'cpu' or 'gpu'.
              if family in available_processors:
                  processor = family
              elif family.startswith("inf"):
                  processor = "inf"
              elif family.startswith("trn"):
                  processor = "trn"
              elif family[0] in ("g", "p"):
                  processor = "gpu"
              else:
                  processor = "cpu"
          else:
              raise ValueError(
                  "Invalid SageMaker instance type: {}. For options, see: "
                  "https://aws.amazon.com/sagemaker/pricing/instance-types".format(
                      instance_type
                  )
              )
  
      _validate_arg(processor, available_processors, "processor")
      return processor
  
imports: from __future__ import absolute_import
  import json
  import logging
  import os
  import re
  from typing import Optional
  from packaging.version import Version
  from sagemaker import utils
  from sagemaker.jumpstart.constants import DEFAULT_JUMPSTART_SAGEMAKER_SESSION
  from sagemaker.jumpstart.utils import is_jumpstart_model_input
  from sagemaker.spark import defaults
  from sagemaker.jumpstart import artifacts
  from sagemaker.workflow import is_pipeline_variable
  from sagemaker.workflow.utilities import override_pipeline_parameter_var
  from sagemaker.fw_utils import GRAVITON_ALLOWED_TARGET_INSTANCE_FAMILY, GRAVITON_ALLOWED_FRAMEWORKS
label_desc: Use image node_id 14 for calling a global function with example usage: _processor(instance_type, available_processors, serverless_inference_config) and returns: processor, None, available_processors, str