code: def collect_activations(
      model_path: str,
      layers: List[str],
      dataset: str,
      data_format: str = None,
      split: str = FULL,
      batch_size: int = 128,
      output_directory: str = "results",
      gpus: List[str] = None,
      gpu_memory_limit: Optional[float] = None,
      allow_parallel_threads: bool = True,
      callbacks: List[Callback] = None,
      backend: Union[Backend, str] = None,
      **kwargs,
  ) -> List[str]:
      """Uses the pretrained model to collect the tensors corresponding to a datapoint in the dataset. Saves the
      tensors to the experiment directory.
  
      # Inputs
  
      :param model_path: (str) filepath to pre-trained model.
      :param layers: (List[str]) list of strings for layer names in the model
          to collect activations.
      :param dataset: (str) source
          containing the data to make predictions.
      :param data_format: (str, default: `None`) format to interpret data
          sources. Will be inferred automatically if not specified.  Valid
          formats are `'auto'`, `'csv'`, `'excel'`, `'feather'`,
          `'fwf'`, `'hdf5'` (cache file produced during previous training),
          `'html'` (file containing a single HTML `<table>`), `'json'`, `'jsonl'`,
          `'parquet'`, `'pickle'` (pickled Pandas DataFrame), `'sas'`, `'spss'`,
          `'stata'`, `'tsv'`.
      :param split: (str, default: `full`) split on which
          to perform predictions. Valid values are `'training'`, `'validation'`,
          `'test'` and `'full'`.
      :param batch_size: (int, default `128`) size of batches for processing.
      :param output_directory: (str, default: `'results'`) the directory that
          will contain the training statistics, TensorBoard logs, the saved
          model and the training progress files.
      :param gpus: (list, default: `None`) list of GPUs that are available
          for training.
      :param gpu_memory_limit: (float: default: `None`) maximum memory fraction
          [0, 1] allowed to allocate per GPU device.
      :param allow_parallel_threads: (bool, default: `True`) allow PyTorch
          to use multithreading parallelism to improve performance at
          the cost of determinism.
      :param callbacks: (list, default: `None`) a list of
          `ludwig.callbacks.Callback` objects that provide hooks into the
          Ludwig pipeline.
      :param backend: (Union[Backend, str]) `Backend` or string name
          of backend to use to execute preprocessing / training steps.
  
      # Return
  
      :return: (List[str]) list of filepath to `*.npy` files containing
          the activations.
      """
      logger.info(f"Dataset path: {dataset}")
      logger.info(f"Model path: {model_path}")
      logger.info(f"Output path: {output_directory}")
      logger.info("\n")
  
      model = LudwigModel.load(
          model_path,
          gpus=gpus,
          gpu_memory_limit=gpu_memory_limit,
          allow_parallel_threads=allow_parallel_threads,
          callbacks=callbacks,
          backend=backend,
      )
  
      # collect activations
      print_boxed("COLLECT ACTIVATIONS")
      collected_tensors = model.collect_activations(
          layers,
          dataset,
          data_format=data_format,
          split=split,
          batch_size=batch_size,
      )
  
      # 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 1 for calling a global function with example usage: collect_activations(model_path, layers, dataset, data_format, split, batch_size, output_directory, gpus, gpu_memory_limit, allow_parallel_threads, callbacks, backend) and returns: saved_filenames