code: def __init__(
      self,
      dim=1000,
      num_ops=100,
      virtual_devices_per_gpu=None,
      device_probabilities=None,
  ):
      self._dim = dim
      self._num_ops = num_ops
      if virtual_devices_per_gpu is None:
          self._virtual_devices_per_gpu = [3]
      else:
          self._virtual_devices_per_gpu = virtual_devices_per_gpu
      self._visible_device_list = [
          i for i in range(len(self._virtual_devices_per_gpu))
      ]
      gpu_devices = [
          ("/gpu:" + str(i))
          for i in range(sum(self._virtual_devices_per_gpu))
      ]
      self.devices = ["/cpu:0"] + gpu_devices
      self._num_devices = len(self.devices)
      # Each virtual device gets 2GB memory.
      self._mem_limits_mb = [
          ([1 << 11] * i) for i in self._virtual_devices_per_gpu
      ]
      self.config = self._GetSessionConfig()
  
      if device_probabilities is not None:
          self._device_probabilities = list(
              device_probabilities
          )  # Deep copy
          for i in range(1, self._num_devices):
              self._device_probabilities[
                  i
              ] += self._device_probabilities[i - 1]
      else:
          # Each device gets same probability to be assigned an operation.
          step = 1.0 / self._num_devices
          self._device_probabilities = [
              (x + 1) * step for x in range(self._num_devices)
          ]
      # To prevent rounding error causing problems.
      self._device_probabilities[self._num_devices - 1] = 1.1
  
      logging.info("dim: %d", self._dim)
      logging.info("num_ops: %d", self._num_ops)
      logging.info(
          "visible_device_list: %s", str(self._visible_device_list)
      )
      logging.info(
          "virtual_devices_per_gpu: %s",
          str(self._virtual_devices_per_gpu),
      )
      logging.info("mem_limits: %s", str(self._mem_limits_mb))
      logging.info("devices: %s", str(self.devices))
      logging.info(
          "config: %s", text_format.MessageToString(self.config)
      )
      logging.info(
          "device_probabilities: %s", str(self._device_probabilities)
      )
  
imports: import random
  import numpy
  from google.protobuf import text_format
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
  from tensorflow.python.platform import tf_logging
label_desc: Use image node_id 1 to create a new VirtualGpuTestUtil object from inherited base classes: object with example: obj = VirtualGpuTestUtil(dim, num_ops, virtual_devices_per_gpu, device_probabilities)