code: def find_supported_fields(
      input_spec: Spec, output_spec: Spec
  ) -> Optional[SupportedFields]:
      """Returns fields from the model specs that are needed for saliency ."""
  
      # Find all ImageGradients fields.
      grad_field_keys = lit_utils.find_spec_keys(
          output_spec, types.ImageGradients
      )
      # Models with more than one gradient field are not supported.
      if not grad_field_keys or len(grad_field_keys) != 1:
          logging.warning(
              "Models must have exactly 1 ImageGradients field, found %i",
              len(grad_field_keys),
          )
          return None
  
      grad_field_key = grad_field_keys[0]
      grad_field_value = cast(
          types.ImageGradients, output_spec[grad_field_key]
      )
  
      # Find image fields that correspond to grad_field.
      image_field_key = grad_field_value.align
      if not isinstance(
          input_spec.get(image_field_key), types.ImageBytes
      ):
          logging.warning(
              "Could not find aligned ImageBytes field, %s, in input spec",
              str(grad_field_value.align),
          )
          return None
  
      # Find gradient target fields in the input if it is a multiclass
      # classification model. The value of None means that it is a regression or
      # single class classification model.
      multiclass = grad_field_value.grad_target_field_key is not None
      if multiclass:
          grad_target_field_key = grad_field_value.grad_target_field_key
          if not isinstance(
              input_spec.get(grad_target_field_key), types.CategoryLabel
          ):
              logging.warning(
                  "Could not find compatible CategoryLabel field, %s, in input spec",
                  str(grad_target_field_key),
              )
              return None
      else:
          grad_target_field_key = None
  
      # Find prediction field names.
      preds_field_keys = lit_utils.find_spec_keys(
          output_spec, _SUPPORTED_PRED_TYPES
      )
      # Models with more than one prediction field are not supported.
      if not preds_field_keys or len(preds_field_keys) != 1:
          logging.warning(
              "Models must have exactly 1 predicition field, found %i",
              len(preds_field_keys),
          )
          return None
      preds_field_key = preds_field_keys[0]
  
      return SupportedFields(
          grad_field_key=grad_field_key,
          image_field_key=image_field_key,
          grad_target_field_key=grad_target_field_key,
          preds_field_key=preds_field_key,
      )
  
imports: import abc
  from collections.abc import Callable
  from typing import Any, NamedTuple, Optional, cast
  from absl import logging
  from lit_nlp.api import components
  from lit_nlp.api import dataset
  from lit_nlp.api import model
  from lit_nlp.api import types
  from lit_nlp.lib import image_utils
  from lit_nlp.lib import utils
  import numpy
  import saliency
label_desc: Use image node_id 1 for calling a global function with example usage: find_supported_fields(input_spec, output_spec) and returns: SupportedFields, None, None, None, None