code: def interpolate_codes(
      codes: Union[np.ndarray, List[np.ndarray]],
      num_samples: int,
      method="spline",
  ):
      """Interpolates latent codes.
  
      Args:
        codes: the codes to interpolate.
        num_samples: the number of samples to interpolate to.
        method: which method to use for interpolation.
  
      Returns:
        (np.ndarray): the interpolated codes.
      """
      if isinstance(codes, list):
          codes = np.array(codes)
      t = np.arange(len(codes))
      xs = np.linspace(0, len(codes) - 1, num_samples)
      if method == "spline":
          cs = interpolate.CubicSpline(t, codes, bc_type="natural")
          return cs(xs).astype(np.float32)
      elif method == "linear":
          interp = interpolate.interp1d(t, codes, axis=0)
          return interp(xs).astype(np.float32)
  
      raise ValueError(f"Unknown method {method!r}")
  
imports: import collections
  from concurrent import futures
  import contextlib
  import functools
  import time
  from typing import List, Union
  import jax
  from jax import tree_util
  import jax.numpy
  import numpy
  from scipy import interpolate
  from scipy.spatial import transform
  import tqdm
label_desc: Use image node_id 7 for calling a global function with example usage: interpolate_codes(codes, num_samples, method) and returns: cs, interp