code: def test_from_save_pretrained_variant(self, expected_max_diff=5e-5):
      (
          init_dict,
          inputs_dict,
      ) = self.prepare_init_args_and_inputs_for_common()
  
      model = self.model_class(**init_dict)
      if hasattr(model, "set_default_attn_processor"):
          model.set_default_attn_processor()
  
      model.to(torch_device)
      model.eval()
  
      with tempfile.TemporaryDirectory() as tmpdirname:
          model.save_pretrained(
              tmpdirname, variant="fp16", safe_serialization=False
          )
          new_model = self.model_class.from_pretrained(
              tmpdirname, variant="fp16"
          )
          if hasattr(new_model, "set_default_attn_processor"):
              new_model.set_default_attn_processor()
  
          # non-variant cannot be loaded
          with self.assertRaises(OSError) as error_context:
              self.model_class.from_pretrained(tmpdirname)
  
          # make sure that error message states what keys are missing
          assert (
              "Error no file named diffusion_pytorch_model.bin found in directory"
              in str(error_context.exception)
          )
  
          new_model.to(torch_device)
  
      with torch.no_grad():
          image = model(**inputs_dict)
          if isinstance(image, dict):
              image = image.to_tuple()[0]
  
          new_image = new_model(**inputs_dict)
  
          if isinstance(new_image, dict):
              new_image = new_image.to_tuple()[0]
  
      max_diff = (image - new_image).abs().max().item()
      self.assertLessEqual(
          max_diff,
          expected_max_diff,
          "Models give different forward passes",
      )
  
imports: import inspect
  import tempfile
  import traceback
  import unittest
  import unittest.mock
  import uuid
  from typing import Dict, List, Tuple
  import numpy
  import requests_mock
  import torch
  from huggingface_hub import delete_repo
  from requests.exceptions import HTTPError
  from diffusers.models import UNet2DConditionModel
  from diffusers.models.attention_processor import AttnProcessor, AttnProcessor2_0, XFormersAttnProcessor
  from diffusers.training_utils import EMAModel
  from diffusers.utils import is_xformers_available, logging
  from diffusers.utils.testing_utils import CaptureLogger, require_python39_or_higher, require_torch_2, require_torch_gpu, run_test_in_subprocess, torch_device
  from ..others.test_utils import TOKEN, USER, is_staging_test
label_desc: Use image node_id 5 for calling the ModelTesterMixin obj's underlying member method code with example usage: obj.test_from_save_pretrained_variant(expected_max_diff) without return types