code: def run_low_shot_logistic_regression(
      config: AttrDict, layer_name: str = "heads"
  ):
      """
      Run the Nearest Neighbour benchmark at the layer "layer_name"
      """
      from sklearn.linear_model import LogisticRegression
      from sklearn.preprocessing import StandardScaler
  
      # -- get train and test features
      feature_dir = config.LOW_SHOT_BENCHMARK.FEATURES.PATH
      (
          train_features,
          train_labels,
          test_features,
          test_labels,
      ) = load_features(feature_dir, layer_name)
  
      # -- Scale the features based on training statistics
      scaler = StandardScaler()
      scaler.fit(train_features)
      train_features = scaler.transform(train_features)
      test_features = scaler.transform(test_features)
  
      # -- Fit Logistic Regression Classifier
      method_config = config.LOW_SHOT_BENCHMARK.LOGISTIC_REGRESSION
      lambdas = method_config.LAMBDA
      if not isinstance(lambdas, list):
          lambdas = [lambdas]
  
      train_scores = []
      test_scores = []
      tried_lambdas = []
      for lambd in lambdas:
          lambd /= len(train_labels)
          classifier = LogisticRegression(
              penalty="l2",
              C=1 / lambd,
              multi_class="multinomial",
          )
          classifier.fit(
              train_features,
              train_labels,
          )
  
          # -- Evaluate on train and test set
          train_score = classifier.score(train_features, train_labels)
          train_scores.append(train_score)
          test_score = classifier.score(test_features, test_labels)
          test_scores.append(test_score)
          tried_lambdas.append(lambd)
          print(f"Lambda: {lambd}, Test Score: {test_score}")
  
      print("Lambdas:", tried_lambdas)
      print("Train scores:", train_scores)
      print("Test scores:", test_scores)
      print("Best train score:", max(train_scores))
      print("Best test score:", max(test_scores))
      return max(test_scores)
  
imports: import logging
  import os
  import numpy
  from vissl.config import AttrDict
  from vissl.hooks import default_hook_generator
  from vissl.models.model_helpers import get_trunk_output_feature_names
  from vissl.utils.checkpoint import get_checkpoint_folder
  from vissl.utils.distributed_launcher import create_submitit_executor, launch_distributed
  from vissl.utils.env import set_env_vars
  from vissl.utils.extract_features_utils import ExtractedFeaturesLoader
  from vissl.utils.hydra_config import print_cfg
  from vissl.utils.logger import setup_logging, shutdown_logging
  from vissl.utils.svm_utils.svm_trainer import SVMTrainer
label_desc: Use image node_id 2 for calling a global function with example usage: run_low_shot_logistic_regression(config, layer_name) and returns: max