@classmethod
  def GetNetwork(cls, vm):
    """Returns a BaseNetwork.

    This method is used instead of directly calling the class's constructor.
    It creates BaseNetwork instances and registers them. If a BaseNetwork
    object has already been registered with the same key, that object
    will be returned rather than creating a new one. This enables multiple
    VMs to call this method and all share the same BaseNetwork object.

    Args:
      vm: The VM for which the Network is being created.
    """
    benchmark_spec = context.GetThreadBenchmarkSpec()
    if benchmark_spec is None:
      raise errors.Error('GetNetwork called in a thread without a '
                         'BenchmarkSpec.')
    spec = cls._GetNetworkSpecFromVm(vm)
    key = cls._GetKeyFromNetworkSpec(spec)
    with benchmark_spec.networks_lock:
      if benchmark_spec.networks not in key:
        benchmark_spec.networks[key] = cls(spec)
      return benchmark_spec.networks[key]
dataset/ETHPy150Open GoogleCloudPlatform/PerfKitBenchmarker/perfkitbenchmarker/network.py/BaseNetwork.GetNetwork/swapped operands of `not in`