code: def collect_weights(
      model_path: str,
      tensors: List[str],
      output_directory: str = "results",
      **kwargs,
  ) -> List[str]:
      """Loads a pretrained model and collects weights.
  
      # Inputs
      :param model_path: (str) filepath to pre-trained model.
      :param tensors: (list, default: `None`) List of tensor names to collect
          weights
      :param output_directory: (str, default: `'results'`) the directory where
          collected weights will be stored.
  
      # Return
  
      :return: (List[str]) list of filepath to `*.npy` files containing
          the weights.
      """
      logger.info(f"Model path: {model_path}")
      logger.info(f"Output path: {output_directory}")
      logger.info("\n")
  
      model = LudwigModel.load(model_path)
  
      # collect weights
      print_boxed("COLLECT WEIGHTS")
      collected_tensors = model.collect_weights(tensors)
  
      # saving
      os.makedirs(output_directory, exist_ok=True)
      saved_filenames = save_tensors(
          collected_tensors, output_directory
      )
  
      logger.info(f"Saved to: {output_directory}")
      return saved_filenames
  
imports: import argparse
  import logging
  import os
  import sys
  from typing import List, Optional, Union
  import numpy
  import torch
  import torchinfo
  from ludwig.api import LudwigModel
  from ludwig.backend import ALL_BACKENDS, Backend
  from ludwig.callbacks import Callback
  from ludwig.constants import FULL, TEST, TRAINING, VALIDATION
  from ludwig.contrib import add_contrib_callback_args
  from ludwig.globals import LUDWIG_VERSION
  from ludwig.utils.print_utils import get_logging_level_registry, print_boxed, print_ludwig
  from ludwig.utils.strings_utils import make_safe_filename
label_desc: Use image node_id 2 for calling a global function with example usage: collect_weights(model_path, tensors, output_directory) and returns: saved_filenames