code: def expand_num_freq(num_freq, param):
      if np.isscalar(num_freq):
          num_freq = [num_freq] * len(param)
      expanded = []
      for _num_freq, par in zip(num_freq, param):
          if np.isscalar(_num_freq) and np.isscalar(par):
              expanded.append(_num_freq)
          elif np.isscalar(_num_freq):
              expanded.append(np.ones_like(par) * _num_freq)
          elif np.isscalar(par):
              raise ValueError(
                  f"{num_freq}\n{param}\n{_num_freq}\n{par}"
              )
          elif len(_num_freq) == len(par):
              expanded.append(_num_freq)
          else:
              raise ValueError()
      return expanded
  
imports: import functools
  import pytest
  from scipy.optimize import shgo
  import pennylane
  from pennylane import numpy
  from pennylane.utils import _flatten, unflatten
  from pennylane.optimize import RotosolveOptimizer
label_desc: Use image node_id 1 for calling a global function with example usage: expand_num_freq(num_freq, param) and returns: expanded