code: def to_numpy(arr, decimals=None):
      if isinstance(arr, torch.Tensor):
          if arr.device.type.startswith("cuda"):
              arr = arr.cpu().detach().numpy()
          else:
              arr = arr.numpy(force=True)
  
      if decimals is None:
          return np.array(arr)
      else:
          return np.array(arr).round(decimals)
  
file_path: pgmpy/pgmpy/utils/compat_fns.py
imports: from copy import deepcopy
  import numpy
  import torch
label_desc: Use image node_id 8 for calling a global function with example usage: to_numpy(arr, decimals) and returns: np, np