code: def _take_torch(tensor, indices, axis=None, **_):
      """Torch implementation of np.take"""
      torch = _i("torch")
  
      if not isinstance(indices, torch.Tensor):
          indices = torch.as_tensor(indices)
  
      if axis is None:
          return tensor.flatten()[indices]
  
      if indices.ndim == 1:
          if (indices < 0).any():
              # index_select doesn't allow negative indices
              dim_length = (
                  tensor.size()[0]
                  if axis is None
                  else tensor.shape[axis]
              )
              indices = torch.where(
                  indices >= 0, indices, indices + dim_length
              )
  
          return torch.index_select(tensor, dim=axis, index=indices)
  
      if axis == -1:
          return tensor[..., indices]
      fancy_indices = [slice(None)] * axis + [indices]
      return tensor[fancy_indices]
  
imports: from importlib import import_module
  import autoray
  import numpy
  import semantic_version
  from scipy.linalg import block_diag
  from .utils import get_deep_interface
label_desc: Use image node_id 28 for calling a global function with example usage: _take_torch(tensor, indices, axis) and returns: tensor, tensor, torch, tensor