code: def compute_hessian(f, params):
      """Compute hessian matrix of given function."""
      h = []
      for i in params:
          h_i = []
          for j in params:
              grad = torch.autograd.grad(f, j, create_graph=True)
              h_ij = torch.autograd.grad(
                  grad, i, allow_unused=True, retain_graph=True
              )
              h_ij = (torch.tensor(0.0),) if h_ij[0] is None else h_ij
              h_i.append(h_ij[0])
          h_i = torch.stack(h_i)
          h.append(h_i)
      h = torch.stack(h)
      h = h.reshape((len(params), len(params)))
      return h
  
imports: import pickle
  import numpy
  import pytest
  import torch
  from garage.torch.optimizers.conjugate_gradient_optimizer import ConjugateGradientOptimizer
  from garage.torch.optimizers.conjugate_gradient_optimizer import _build_hessian_vector_product
  from garage.torch.optimizers.conjugate_gradient_optimizer import _conjugate_gradient
label_desc: Use image node_id 5 for calling a global function with example usage: compute_hessian(f, params) and returns: h