code: def rastrigin(x):
      """Rastrigin objective function.
  
      Has a global minimum at :code:`f(0,0,...,0)` with a search
      domain of :code:`[-5.12, 5.12]`
  
      Parameters
      ----------
      x : numpy.ndarray
          set of inputs of shape :code:`(n_particles, dimensions)`
  
      Returns
      -------
      numpy.ndarray
          computed cost of size :code:`(n_particles, )`
  
      Raises
      ------
      ValueError
          When the input is out of bounds with respect to the function
          domain
      """
      if not np.logical_and(x >= -5.12, x <= 5.12).all():
          raise ValueError(
              "Input for Rastrigin function must be within "
              "[-5.12, 5.12]."
          )
  
      d = x.shape[1]
      j = 10.0 * d + (x**2.0 - 10.0 * np.cos(2.0 * np.pi * x)).sum(
          axis=1
      )
  
      return j
  
file_path: pyswarms/pyswarms/utils/functions/single_obj.py
imports: import numpy
label_desc: Use image node_id 13 for calling a global function with example usage: rastrigin(x) and returns: j