code: def test_initialize_pytorch_only_once(mock_torch):
      mock_torch.cuda.is_available.return_value = True
      mock_torch.cuda.device_count.return_value = 4
      with clean_params():
          # During first time initialization, set pytorch parallelism
          initialize_pytorch(allow_parallel_threads=False)
          mock_torch.set_num_threads.assert_called_once()
          mock_torch.set_num_interop_threads.assert_called_once()
  
          # Reset call counts on all threading calls
          mock_torch.reset_mock()
  
          # In the second call to initialization, avoid calling these methods again, as pytorch
          # will raise an exception
          initialize_pytorch(allow_parallel_threads=False)
          mock_torch.set_num_threads.assert_not_called()
          mock_torch.set_num_interop_threads.assert_not_called()
  
      # No GPUs were specified, so this should not have been called even once
      mock_torch.cuda.memory.set_per_process_memory_fraction.assert_not_called()
  
file_path: ludwig/tests/ludwig/utils/test_torch_utils.py
imports: import contextlib
  import os
  from typing import List
  from unittest.mock import patch
  import pytest
  import torch
  from ludwig.utils.torch_utils import _get_torch_init_params, _set_torch_init_params, initialize_pytorch, sequence_length_2D, sequence_length_3D
label_desc: Use image node_id 4 for calling a global function with example usage: test_initialize_pytorch_only_once(mock_torch) without return types