code: def to_np(v):
      '''returns an np.array object given an input of np.array, list, tuple, torch variable or tensor.'''
      if isinstance(v, float): return np.array(v)
      if isinstance(v, (np.ndarray, np.generic)): return v
      if isinstance(v, (list,tuple)): return [to_np(o) for o in v]
      if isinstance(v, Variable): v=v.data
      if torch.cuda.is_available():
          if is_half_tensor(v): v=v.float()
      if isinstance(v, torch.FloatTensor): v=v.float()
      return v.cpu().numpy(f to_np(v):
      '''returns an np.array object given an input of np.array, list, tuple, torch variable or tensor.'''
      if isinstance(v, float): return np.array(v)
      if isinstance(v, (np.ndarray, np.generic)): return v
      if isinstance(v, (list,tuple)): return [to_np(o) for o in v]
      if isinstance(v, Variable): v=v.data
      if torch.cuda.is_available():
          if is_half_tensor(v): v=v.float()
      if isinstance(v, torch.FloatTensor): v=v.float()
      return v.cpu().numpy()
docs: returns an np.array object given an input of np.array, list, tuple, torch variable or tensor.