code: def generate_clip_weights(args, classnames, template, predictor):
      with torch.no_grad():
          clip_weights = []
          for classname in classnames:
              classname = classname.replace("_", " ")
              text = {"text": [t.format(classname) for t in template]}
              class_embeddings = extract_embedding(
                  args, text, predictor, ["text"]
              )
              class_embeddings /= class_embeddings.norm(
                  dim=-1, keepdim=True
              )
              class_embedding = class_embeddings.mean(dim=0)
              class_embedding /= class_embedding.norm()
              clip_weights.append(class_embedding)
          clip_weights = torch.stack(clip_weights, dim=1).cuda()
  
      return clip_weights
  
imports: import torch
  import pandas
  from tqdm import tqdm
  import torch.nn.functional
  import torch.nn
  from autogluon.multimodal import MultiModalPredictor
  from datasets import list_datasets, load_dataset
  from setfit import sample_dataset
  from imagedatasets import build_dataset
  from torch.utils.data import Dataset
label_desc: Use image node_id 5 for calling a global function with example usage: generate_clip_weights(args, classnames, template, predictor) and returns: clip_weights