code: def get_logits(
      snapshot_path: str,
      use_cuda_if_available: bool,
      output_path: Optional[str] = None,
      test_path: Optional[str] = None,
      field_names: Optional[List[str]] = None,
      dump_raw_input: bool = False,
      batch_size: int = 16,
      ndigits_precision: int = 0,
      output_columns: Optional[List[int]] = None,
      use_gzip: bool = False,
      device_id: int = 0,
      fp16: bool = False,
  ):
      _set_cuda(use_cuda_if_available, device_id)
      task, train_config, _training_state = load(snapshot_path)
      print(f"Successfully loaded model from {snapshot_path}")
      print(f"Model on GPU? {next(task.model.parameters()).is_cuda}")
      print(f"CUDA device id: {torch.cuda.current_device()}")
  
      if isinstance(task, NewTask):
          task.model.eval()
  
          if fp16:
              task.model.half()
  
          data_source = _get_data_source(
              test_path, train_config.task.data, field_names, task
          )
          task.data.batcher = Batcher(test_batch_size=batch_size)
          task.data.sort_key = None
          batches = task.data.batches(
              Stage.TEST, data_source=data_source
          )
  
          mp = torch.multiprocessing.get_context("spawn")
  
          with torch.no_grad():
              results = mp.SimpleQueue()
              logits_writer = LogitsWriter(
                  results, output_path, use_gzip, ndigits_precision
              )
              logits_writer_ctx = torch.multiprocessing.spawn(
                  logits_writer.run, join=False
              )
  
              for raw_batch, tensor_dict in batches:
                  raw_input_tuple = (
                      dict_zip(*raw_batch, value_only=True)
                      if dump_raw_input
                      else ()
                  )
  
                  model_inputs = task.model.arrange_model_inputs(
                      tensor_dict
                  )
                  model_outputs = task.model(*model_inputs)
  
                  # multi-encoder output
                  if isinstance(model_outputs, tuple):
                      # prevent breaking behaviour in default case
                      output_columns = (
                          range(len(model_outputs))
                          if not output_columns
                          else output_columns
                      )
                      model_outputs = tuple(
                          m.tolist()
                          for i, m in enumerate(model_outputs)
                          if i in output_columns
                      )
                  # single encoder output
                  elif isinstance(model_outputs, list):
                      model_outputs = model_outputs.tolist()
                  else:
                      raise Exception(
                          "Expecting tuple or tensor types for model_outputs"
                      )
  
                  results.put((raw_input_tuple, model_outputs))
  
              results.put((None, None))
              logits_writer_ctx.join()
              print(
                  f"Finished logits generation for file {test_path} with output {output_path}"
              )
  
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 14 for calling a global function with example usage: get_logits(snapshot_path, use_cuda_if_available, output_path, test_path, field_names, dump_raw_input, batch_size, ndigits_precision, output_columns, use_gzip, device_id, fp16) without return types