code: def test_explained_variance_1d():
      y = np.array([1, 2, 3, 4, 5, 0, 0, 0, 0, 0])
      y_hat = np.array([2, 3, 4, 5, 6, 0, 0, 0, 0, 0])
      valids = np.array([1, 1, 1, 1, 1, 0, 0, 0, 0, 0])
      result = explained_variance_1d(y, y_hat, valids)
      assert result == 1.0
      result = explained_variance_1d(y, y_hat)
      np.testing.assert_almost_equal(result, 0.95)
  
file_path: garage/tests/garage/np/test_functions.py
imports: import warnings
  import numpy
  from garage.np import concat_tensor_dict_list, explained_variance_1d, pad_batch_array, pad_tensor, stack_and_pad_tensor_dict_list, stack_tensor_dict_list
label_desc: Use image node_id 4 for calling a global function with example usage: test_explained_variance_1d() without return types