code: def similarity_fn(path1, path2):
      if not (path1 and path2):
          return '<b style="color:red">ERROR: Please record audio for *both* speakers!</b>'
  
      wav1, _ = apply_effects_file(path1, EFFECTS)
      wav2, _ = apply_effects_file(path2, EFFECTS)
      print(wav1.shape, wav2.shape)
  
      input1 = feature_extractor(
          wav1.squeeze(0), return_tensors="pt", sampling_rate=16000
      ).input_values.to(device)
      input2 = feature_extractor(
          wav2.squeeze(0), return_tensors="pt", sampling_rate=16000
      ).input_values.to(device)
  
      with torch.no_grad():
          emb1 = model(input1).embeddings
          emb2 = model(input2).embeddings
      emb1 = torch.nn.functional.normalize(emb1, dim=-1).cpu()
      emb2 = torch.nn.functional.normalize(emb2, dim=-1).cpu()
      similarity = cosine_sim(emb1, emb2).numpy()[0]
  
      if similarity >= THRESHOLD:
          output = OUTPUT_OK.format(similarity * 100)
      else:
          output = OUTPUT_FAIL.format(similarity * 100)
  
      return output
  
imports: import gradio
  import torch
  from torchaudio.sox_effects import apply_effects_file
  from transformers import AutoFeatureExtractor, AutoModelForAudioXVector
label_desc: Use image node_id 1 for calling a global function with example usage: similarity_fn(path1, path2) and returns: output, str