docstr: Check an operation against a dense equivalent
docstr_tok: ["Check","an","operation","against","a","dense","equivalent"]
code: def _CheckAgainstDense(
      self,
      dense_op,
      sparse_op,
      args_maker,
      check_jit=True,
      check_dtypes=True,
      tol=None,
      atol=None,
      rtol=None,
      canonicalize_dtypes=True,
  ):
      """Check an operation against a dense equivalent"""
      sparse_args = args_maker()
      dense_args = tree_util.tree_map(
          sparse.todense, sparse_args, is_leaf=is_sparse
      )
      expected = dense_op(*dense_args)
  
      sparse_ans = sparse_op(*sparse_args)
      actual = tree_util.tree_map(
          sparse.todense, sparse_ans, is_leaf=is_sparse
      )
  
      self.assertAllClose(
          expected,
          actual,
          check_dtypes=check_dtypes,
          atol=atol or tol,
          rtol=rtol or tol,
          canonicalize_dtypes=canonicalize_dtypes,
      )
      if check_jit:
          sparse_ans_jit = jax.jit(sparse_op)(*sparse_args)
          self.assertSparseArraysEquivalent(
              sparse_ans,
              sparse_ans_jit,
              atol=atol or tol,
              rtol=rtol or tol,
          )
  
imports: from __future__ import annotations
  from collections.abc import Iterable, Iterator, Sequence
  import functools
  import itertools
  import math
  from typing import Any, Callable, Union
  from typing import NamedTuple
  import jax
  from jax import lax
  from jax import tree_util
  from jax._src import test_util
  from jax._src.lax.lax import DotDimensionNumbers
  from jax._src.lib import gpu_sparse
  from jax._src.typing import DTypeLike
  from jax.experimental import sparse
  import jax.numpy
  from jax.util import safe_zip, split_list
  import numpy
label_desc: Use image node_id 2 for calling the SparseTestCase obj's underlying member method code with example usage: obj._CheckAgainstDense(dense_op, sparse_op, args_maker, check_jit, check_dtypes, tol, atol, rtol, canonicalize_dtypes) without return types