code: def test_env_var_parsing(self):
      def _parse_visible_devices(val):
          from torch.cuda import _parse_visible_devices as _pvd
  
          with patch.dict(
              os.environ, {"CUDA_VISIBLE_DEVICES": val}, clear=True
          ):
              return _pvd()
  
      # rest of the string is ignored
      self.assertEqual(_parse_visible_devices("1gpu2,2ampere"), [1, 2])
      # Negatives abort parsing
      self.assertEqual(
          _parse_visible_devices("0, 1, 2, -1, 3"), [0, 1, 2]
      )
      # Double mention of ordinal returns empty set
      self.assertEqual(_parse_visible_devices("0, 1, 2, 1"), [])
      # Unary pluses and minuses
      self.assertEqual(
          _parse_visible_devices("2, +3, -0, 5"), [2, 3, 0, 5]
      )
      # Random string is used as empty set
      self.assertEqual(_parse_visible_devices("one,two,3,4"), [])
      # Random string is used as separator
      self.assertEqual(_parse_visible_devices("4,3,two,one"), [4, 3])
      # GPU ids are parsed
      self.assertEqual(
          _parse_visible_devices("GPU-9e8d35e3"), ["GPU-9e8d35e3"]
      )
      # Ordinals are not included in GPUid set
      self.assertEqual(
          _parse_visible_devices("GPU-123, 2"), ["GPU-123"]
      )
      # MIG ids are parsed
      self.assertEqual(
          _parse_visible_devices("MIG-89c850dc"), ["MIG-89c850dc"]
      )
  
file_path: pytorch/test/test_cuda_nvml_based_avail.py
imports: import os
  import sys
  import multiprocessing
  import torch
  import unittest
  from unittest.mock import patch
label_desc: Use image node_id 1 for calling the TestVisibleDeviceParses obj's underlying member method code with example usage: obj.test_env_var_parsing() and returns: _pvd