code: def _copy_tensor(
      t: _torch.Tensor,
      safe_copy: bool,
      device: _typing.Optional[_torch.device] = None,
  ) -> _torch.Tensor:
      if safe_copy:
          t = t.clone().detach().requires_grad_(t.requires_grad)
      else:
          t = t.detach().requires_grad_(t.requires_grad)
      t = t if device is None else t.to(device)
      return t
  
file_path: higher/higher/utils.py
imports: import torch
  import typing
label_desc: Use image node_id 1 for calling a global function with example usage: _copy_tensor(t, safe_copy, device) and returns: t