code: def is_safetensors_compatible(
      filenames, variant=None, passed_components=None
  ) -> bool:
      """
      Checking for safetensors compatibility:
      - By default, all models are saved with the default pytorch serialization, so we use the list of default pytorch
        files to know which safetensors files are needed.
      - The model is safetensors compatible only if there is a matching safetensors file for every default pytorch file.
  
      Converting default pytorch serialized filenames to safetensors serialized filenames:
      - For models from the diffusers library, just replace the ".bin" extension with ".safetensors"
      - For models from the transformers library, the filename changes from "pytorch_model" to "model", and the ".bin"
        extension is replaced with ".safetensors"
      """
      pt_filenames = []
  
      sf_filenames = set()
  
      passed_components = passed_components or []
  
      for filename in filenames:
          _, extension = os.path.splitext(filename)
  
          if (
              len(filename.split("/")) == 2
              and filename.split("/")[0] in passed_components
          ):
              continue
  
          if extension == ".bin":
              pt_filenames.append(os.path.normpath(filename))
          elif extension == ".safetensors":
              sf_filenames.add(os.path.normpath(filename))
  
      for filename in pt_filenames:
          #  filename = 'foo/bar/baz.bam' -> path = 'foo/bar', filename = 'baz', extention = '.bam'
          path, filename = os.path.split(filename)
          filename, extension = os.path.splitext(filename)
  
          if filename.startswith("pytorch_model"):
              filename = filename.replace("pytorch_model", "model")
          else:
              filename = filename
  
          expected_sf_filename = os.path.normpath(
              os.path.join(path, filename)
          )
          expected_sf_filename = f"{expected_sf_filename}.safetensors"
          if expected_sf_filename not in sf_filenames:
              logger.warning(f"{expected_sf_filename} not found")
              return False
  
      return True
  
imports: import fnmatch
  import importlib
  import inspect
  import os
  import re
  import sys
  import warnings
  from dataclasses import dataclass
  from pathlib import Path
  from typing import Any, Callable, Dict, List, Optional, Union
  import numpy
  import PIL.Image
  import requests
  import torch
  from huggingface_hub import ModelCard, create_repo, hf_hub_download, model_info, snapshot_download
  from huggingface_hub.utils import OfflineModeIsEnabled, validate_hf_hub_args
  from packaging import version
  from requests.exceptions import HTTPError
  from tqdm.auto import tqdm
  from ..None import __version__
  from ..configuration_utils import ConfigMixin
  from ..models.modeling_utils import _LOW_CPU_MEM_USAGE_DEFAULT
  from ..schedulers.scheduling_utils import SCHEDULER_CONFIG_NAME
  from ..utils import CONFIG_NAME, DEPRECATED_REVISION_ARGS, SAFETENSORS_WEIGHTS_NAME, WEIGHTS_NAME, BaseOutput, deprecate, get_class_from_dynamic_module, is_accelerate_available, is_accelerate_version, is_peft_available, is_torch_version, is_transformers_available, logging, numpy_to_pil
  from ..utils.torch_utils import is_compiled_module
  from ..utils import FLAX_WEIGHTS_NAME, ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, PushToHubMixin
label_desc: Use image node_id 1 for calling a global function with example usage: is_safetensors_compatible(filenames, variant, passed_components) and returns: True, False