class_docstr: Torch autograd function for matrix logarithm.
  
  Implementation based on:
  https://github.com/pytorch/pytorch/issues/9983#issuecomment-891777620
class_docstr_tok: ["Torch","autograd","function","for","matrix","logarithm",".","Implementation","based","on",":","https",":","\/\/github.com\/pytorch\/pytorch\/issues\/9983","#","issuecomment-891777620"]
docstr: Run gradients backward.
docstr_tok: ["Run","gradients","backward","."]
code: def backward(ctx, grad):
      """Run gradients backward."""
      (tensor,) = ctx.saved_tensors
  
      vectorized = tensor.ndim == 3
      axes = (0, 2, 1) if vectorized else (1, 0)
      tensor_H = tensor.permute(axes).conj().to(grad.dtype)
      n = tensor.size(-1)
      bshape = tensor.shape[:-2] + (2 * n, 2 * n)
      backward_tensor = _torch.zeros(
          *bshape, dtype=grad.dtype, device=grad.device
      )
      backward_tensor[..., :n, :n] = tensor_H
      backward_tensor[..., n:, n:] = tensor_H
      backward_tensor[..., :n, n:] = grad
  
      return _Logm._logm(backward_tensor).to(tensor.dtype)[..., :n, n:]
  
file_path: geomstats/geomstats/_backend/pytorch/linalg.py
imports: import numpy
  import scipy
  import torch
  from .._backend_config import np_atol
  from ..numpy import linalg
  from ._dtype import _cast_out_to_input_dtype
label_desc: Use image node_id 3 for calling the _Logm obj's underlying member method code with example usage: obj.backward(ctx, grad) and returns: _Logm