parameters: (pad_values, ndim)
return_statement: return pad_values
docstring: broadcasts the pad_values to (ndim * 2)
docstring_summary: broadcasts the pad_values to (ndim * 2)
docstring_tokens: broadcasts the pad_values to ( ndim * 2 )
function: def _convert_pad_to_nd(pad_values, ndim):
      """broadcasts the pad_values to (ndim * 2)"""
      if not isinstance(pad_values, (int, list, tuple, Tensor)):
          raise TypeError(
              "pad_width, stat_length, constant_values or end_values should only be int, list, tuple or tensor")
      pad_tensor = _to_tensor(pad_values)
      pad_shape = pad_tensor.shape
      if not pad_shape:
          pad_values = tuple((((pad_values,) * 2) for i in range(ndim)))
      elif pad_shape == (1,):
          pad_values = tuple((tuple(pad_values) * 2) for i in range(ndim))
      elif pad_shape == (2,):
          pad_values = tuple(tuple(pad_values) for i in range(ndim))
      elif pad_shape == (1, 2):
          pad_values = tuple(tuple(pad_values[0]) for i in range(ndim))
      elif pad_shape == (ndim, 2):
          pad_values = tuple(tuple(pad_pair) for pad_pair in pad_values)
      else:
          raise ValueError(f"input values must be able to broadcast to {(ndim, 2)}")
      return pad_values
function_tokens: def _convert_pad_to_nd ( pad_values , ndim ) : if not isinstance ( pad_values , ( int , list , tuple , Tensor ) ) : raise TypeError ( "pad_width, stat_length, constant_values or end_values should only be int, list, tuple or tensor" ) pad_tensor = _to_tensor ( pad_values ) pad_shape = pad_tensor . shape if not pad_shape : pad_values = tuple ( ( ( ( pad_values , ) * 2 ) for i in range ( ndim ) ) ) elif pad_shape == ( 1 , ) : pad_values = tuple ( ( tuple ( pad_values ) * 2 ) for i in range ( ndim ) ) elif pad_shape == ( 2 , ) : pad_values = tuple ( tuple ( pad_values ) for i in range ( ndim ) ) elif pad_shape == ( 1 , 2 ) : pad_values = tuple ( tuple ( pad_values [ 0 ] ) for i in range ( ndim ) ) elif pad_shape == ( ndim , 2 ) : pad_values = tuple ( tuple ( pad_pair ) for pad_pair in pad_values ) else : raise ValueError ( f"input values must be able to broadcast to {(ndim, 2)}" ) return pad_values