code: def polyval(p, x):
      """Evaluates a polynomial at specific values.
  
      Args:
          p (cupy.ndarray or cupy.poly1d): input polynomial.
          x (scalar, cupy.ndarray): values at which the polynomial
          is evaluated.
  
      Returns:
          cupy.ndarray or cupy.poly1d: polynomial evaluated at x.
  
      .. warning::
  
          This function doesn't currently support poly1d values to evaluate.
  
      .. seealso:: :func:`numpy.polyval`
  
      """
      if isinstance(p, cupy.poly1d):
          p = p.coeffs
      if not isinstance(p, cupy.ndarray) or p.ndim == 0:
          raise TypeError("p must be 1d ndarray or poly1d object")
      if p.ndim > 1:
          raise ValueError("p must be 1d array")
      if isinstance(x, cupy.poly1d):
          # TODO(asi1024): Needs performance improvement.
          dtype = numpy.result_type(x.coeffs, 1)
          res = cupy.poly1d(cupy.array([0], dtype=dtype))
          prod = cupy.poly1d(cupy.array([1], dtype=dtype))
          for c in p[::-1]:
              res = res + prod * c
              prod = prod * x
          return res
      dtype = numpy.result_type(p.dtype.type(0), x)
      p = p.astype(dtype, copy=False)
      if p.size == 0:
          return cupy.zeros(x.shape, dtype)
      if dtype == numpy.bool_:
          return p.any() * x + p[-1]
      if not cupy.isscalar(x):
          x = cupy.asarray(x, dtype=dtype)[..., None]
      x = x ** cupy.arange(p.size, dtype=dtype)
      return (p[::-1] * x).sum(axis=-1, dtype=dtype)
  
file_path: cupy/cupy/lib/_routines_poly.py
imports: import functools
  import warnings
  import numpy
  import cupy
  import cupyx.scipy.fft
label_desc: Use image node_id 10 for calling a global function with example usage: polyval(p, x) and returns: unknown, res, cupy, unknown