class_docstr: A term that is compiled to a HSGP term in PyMC
  
  This instance contains information of a bambi.HSGPTerm and knows how to build the distributions
  in PyMC that represent the HSGP latent approximation.
  
  Parameters
  ----------
  term : bambi.terms.HSGPTerm
      An object representing a Bambi hsgp term.
class_docstr_tok: ["A","term","that","is","compiled","to","a","HSGP","term","in","PyMC","This","instance","contains","information","of","a","bambi.HSGPTerm","and","knows","how","to","build","the","distributions","in","PyMC","that","represent","the","HSGP","latent","approximation",".","Parameters","--","--","--","--","--","term",":","bambi.terms.HSGPTerm","An","object","representing","a","Bambi","hsgp","term","."]
docstr: Construct and return the covariance function
  
  This method uses the name of the covariance function to retrieve a callable that
  returns a GP kernel and the name of its parameters. Then it looks for values for the
  parameters in the dictionary of priors of the term (building PyMC distributions as needed)
  and finally it determines the value of 'input_dim' if that is required by the callable
  that produces the covariance function. If that is the case, 'input_dim' is set to the
  dimensionality of the GP component -- the number of columns in the data.
  
  Returns
  -------
  Sequence[pm.gp.Covariance]
      A covariance function that can be used with a GP in PyMC
docstr_tok: ["Construct","and","return","the","covariance","function","This","method","uses","the","name","of","the","covariance","function","to","retrieve","a","callable","that","returns","a","GP","kernel","and","the","name","of","its","parameters",".","Then","it","looks","for","values","for","the","parameters","in","the","dictionary","of","priors","of","the","term","(","building","PyMC","distributions","as","needed",")","and","finally","it","determines","the","value","of","'input_dim","'","if","that","is","required","by","the","callable","that","produces","the","covariance","function",".","If","that","is","the","case",",","'input_dim","'","is","set","to","the","dimensionality","of","the","GP","component","--","the","number","of","columns","in","the","data",".","Returns","--","--","--","-","Sequence","[","pm.gp.Covariance","]","A","covariance","function","that","can","be","used","with","a","GP","in","PyMC"]
code: def get_covariance_functions(self):
      """Construct and return the covariance function
  
      This method uses the name of the covariance function to retrieve a callable that
      returns a GP kernel and the name of its parameters. Then it looks for values for the
      parameters in the dictionary of priors of the term (building PyMC distributions as needed)
      and finally it determines the value of 'input_dim' if that is required by the callable
      that produces the covariance function. If that is the case, 'input_dim' is set to the
      dimensionality of the GP component -- the number of columns in the data.
  
      Returns
      -------
      Sequence[pm.gp.Covariance]
          A covariance function that can be used with a GP in PyMC
      """
  
      # Get the callable that creates the function
      cov_dict = GP_KERNELS[self.term.cov]
      create_covariance_function = cov_dict["fn"]
      param_names = cov_dict["params"]
      params = {}
  
      # Set dimensions and behavior for priors that are actually fixed (floats or ints)
      if self.term.by_levels is not None and not self.term.share_cov:
          dims = (f"{self.name}_by",)
          recycle = True
      else:
          dims = None
          recycle = False
  
      # Build priors and parameters
      for param_name in param_names:
          prior = self.term.prior[param_name]
          param_dims = dims
          if isinstance(prior, Prior):
              distribution = get_distribution_from_prior(prior)
              # varying lengthscale parameter
              if (
                  param_name == "ell"
                  and not self.term.iso
                  and self.term.shape[1] > 1
              ):
                  if param_dims is not None:
                      param_dims = (f"{self.name}_var",) + param_dims
                  else:
                      param_dims = (f"{self.name}_var",)
              value = distribution(
                  f"{self.name}_{param_name}",
                  **prior.args,
                  dims=param_dims,
              )
          else:
              # If it's not a distribution, but a scalar...
              if recycle:
                  value = (prior,) * self.term.groups_n
              else:
                  value = prior
          params[param_name] = value
  
      if "input_dim" in list(
          inspect.signature(create_covariance_function).parameters
      ):
          if self.term.groups_n > 1 and not self.term.share_cov:
              params["input_dim"] = np.repeat(
                  self.term.shape[1], self.term.groups_n
              )
          else:
              params["input_dim"] = self.term.shape[1]
  
      if self.term.groups_n == 1 or self.term.share_cov:
          covariance_function = create_covariance_function(**params)
          output = [covariance_function] * self.term.groups_n
      else:
          output = []
          for i, _ in enumerate(self.term.by_levels):
              params_level = {}
              for key, value in params.items():
                  if value[..., i].ndim == 0 and isinstance(
                      value, np.ndarray
                  ):
                      entry = value[..., i].item()
                  else:
                      entry = value[..., i]
                  params_level[key] = entry
              covariance_function = create_covariance_function(
                  **params_level
              )
              output.append(covariance_function)
      return output
  
imports: import inspect
  import numpy
  import pymc
  import pytensor.tensor
  from bambi.backend.utils import get_distribution_from_likelihood, get_distribution_from_prior, get_linkinv, has_hyperprior, make_weighted_distribution, GP_KERNELS
  from bambi.families.multivariate import MultivariateFamily, Multinomial, DirichletMultinomial
  from bambi.families.univariate import Categorical
  from bambi.priors import Prior
  from bambi.utils import get_aliased_name
label_desc: Use image node_id 3 for calling the HSGPTerm obj's underlying member method code with example usage: obj.get_covariance_functions() and returns: output