code: def mock_pynvml_module():
      with patch.dict(
          "sys.modules",
          {
              "pynvml": Mock(name="pynvml"),
              "pynvml.smi": Mock(name="pynvml.smi"),
              "pynvml.smi.nvidia_smi": Mock(
                  name="pynvml.smi.nvidia_smi"
              ),
          },
      ):
          import pynvml
          from pynvml.smi import nvidia_smi
  
          def query(*args, **kwargs):
              return query_resp
  
          def getInstance():
              nvsmi = Mock()
              nvsmi.DeviceQuery = Mock(side_effect=query)
              return nvsmi
  
          nvidia_smi.getInstance = Mock(side_effect=getInstance)
          yield pynvml
  
file_path: ignite/tests/ignite/contrib/metrics/test_gpu_info.py
imports: from unittest.mock import Mock, patch
  import pytest
  import torch
  from ignite.contrib.metrics import GpuInfo
  from ignite.engine import Engine, State
label_desc: Use image node_id 5 for calling a global function with example usage: mock_pynvml_module() and returns: query_resp, nvsmi