code: def test_model_from_snapshot_path(
      snapshot_path: str,
      use_cuda_if_available: bool,
      test_path: Optional[str] = None,
      metric_channels: Optional[List[Channel]] = None,
      test_out_path: str = "",
      field_names: Optional[List[str]] = None,
  ):
      _set_cuda(use_cuda_if_available)
      task, train_config, _training_state = load(snapshot_path)
  
      for mc in metric_channels or []:
          task.metric_reporter.add_channel(mc)
  
      # Overwrite the test output path because you might not have permission to
      # write to the original test output path that was created when model was trained.
      if test_out_path:
          if hasattr(task.metric_reporter, "output_path"):
              task.metric_reporter.output_path = test_out_path
          for channel in task.metric_reporter.channels:
              if hasattr(channel, "file_path"):
                  channel.file_path = test_out_path
      else:
          test_out_path = train_config.task.metric_reporter.output_path
  
      if isinstance(task, (NewTask, NewDisjointMultitask)):
          data_source = _get_data_source(
              test_path, train_config.task.data, field_names, task
          )
          test_results = task.test(data_source)
      else:
          if not test_path:
              test_path = train_config.task.data_handler.test_path
          test_results = task.test(test_path)
      return test_results, test_out_path, metric_channels
  
imports: import gzip
  import json
  import os
  import sys
  import traceback
  from typing import Any, Dict, get_type_hints, IO, Iterator, List, Optional, Tuple, Union
  import torch
  from pytext.common.constants import Stage
  from pytext.config import ExportConfig, PyTextConfig, TestConfig
  from pytext.config.component import ComponentType, create_component, create_exporter
  from pytext.data.data import Batcher
  from pytext.data.data_handler import CommonMetadata
  from pytext.metric_reporters.channel import Channel
  from pytext.task import create_task, get_latest_checkpoint_path, load, NewTask, save, Task_Deprecated
  from pytext.task.disjoint_multitask import NewDisjointMultitask
  from pytext.trainers import TrainingState
  from pytext.utils import cuda, distributed, precision, round_seq, set_random_seeds, timing
  from pytext.utils.file_io import PathManager
label_desc: Use image node_id 12 for calling a global function with example usage: test_model_from_snapshot_path(snapshot_path, use_cuda_if_available, test_path, metric_channels, test_out_path, field_names) and returns: test_results,  test_out_path,  metric_channels