docstr: Setup the compute backend.
  
  Parameters
  ----------
  backend: str (numpy or torch)
      Sets the compute backend to `backend`.
  
  device: str (default: None)
      Sets the device for torch backend. For numpy backend, sets device=None.
      If None, sets device to the first gpu if available else cpu.
  
  dtype: Instance of numpy.dtype or torch.dtype (default: None)
      Sets the dtype for arrays. If None, sets to either numpy.float64 or
      torch.float64 depending on the backend.
docstr_tok: ["Setup","the","compute","backend",".","Parameters","--","--","--","--","--","backend",":","str","(","numpy","or","torch",")","Sets","the","compute","backend","to","`","backend","`",".","device",":","str","(","default",":","None",")","Sets","the","device","for","torch","backend",".","For","numpy","backend",",","sets","device=None",".","If","None",",","sets","device","to","the","first","gpu","if","available","else","cpu",".","dtype",":","Instance","of","numpy.dtype","or","torch.dtype","(","default",":","None",")","Sets","the","dtype","for","arrays",".","If","None",",","sets","to","either","numpy.float64","or","torch.float64","depending","on","the","backend","."]
code: def set_backend(self, backend, device=None, dtype=None):
      """
      Setup the compute backend.
  
      Parameters
      ----------
      backend: str (numpy or torch)
          Sets the compute backend to `backend`.
  
      device: str (default: None)
          Sets the device for torch backend. For numpy backend, sets device=None.
          If None, sets device to the first gpu if available else cpu.
  
      dtype: Instance of numpy.dtype or torch.dtype (default: None)
          Sets the dtype for arrays. If None, sets to either numpy.float64 or
          torch.float64 depending on the backend.
      """
      if backend not in ["numpy", "torch"]:
          raise ValueError(
              f"backend can either be `numpy` or `torch`. Got: {backend}"
          )
  
      if backend == "numpy":
          self.BACKEND = "numpy"
          self.DEVICE = None
      else:
          self.BACKEND = "torch"
          self.set_device(device)
      self.set_dtype(dtype=dtype)
  
file_path: pgmpy/pgmpy/global_vars.py
imports: import logging
  import numpy
  import torch
label_desc: Use image node_id 4 for calling the Config obj's underlying member method code with example usage: obj.set_backend(backend, device, dtype) without return types