original_docstring: Test that tensors in diverse containers are equal.
docstring: Test that tensors in diverse containers are equal.
docstring_tokens: Test that tensors in diverse containers are equal .
code: def tensors_equal(self, x, y):
          """"Test that tensors in diverse containers are equal."""
          if isinstance(x, PackedSequence):
              return self.tensors_equal(x[0], y[0]) and self.tensors_equal(x[1], y[1])
  
          if isinstance(x, dict):
              return (
                  (x.keys() == y.keys()) and
                  all(self.tensors_equal(x[k], y[k]) for k in x)
              )
  
          if isinstance(x, (list, tuple)):
              return all(self.tensors_equal(xi, yi) for xi, yi in zip(x, y))
  
          if x.is_sparse is not y.is_sparse:
              return False
  
          if x.is_sparse:
              x, y = x.to_dense(), y.to_dense()
  
          return (x == y).all()
code_tokens: def tensors_equal ( self , x , y ) : if isinstance ( x , PackedSequence ) : return self . tensors_equal ( x [ 0 ] , y [ 0 ] ) and self . tensors_equal ( x [ 1 ] , y [ 1 ] ) if isinstance ( x , dict ) : return ( ( x . keys ( ) == y . keys ( ) ) and all ( self . tensors_equal ( x [ k ] , y [ k ] ) for k in x ) ) if isinstance ( x , ( list , tuple ) ) : return all ( self . tensors_equal ( xi , yi ) for xi , yi in zip ( x , y ) ) if x . is_sparse is not y . is_sparse : return False if x . is_sparse : x , y = x . to_dense ( ) , y . to_dense ( ) return ( x == y ) . all ( )
short_docstring: Test that tensors in diverse containers are equal.
short_docstring_tokens: Test that tensors in diverse containers are equal .
comment: """"Test that tensors in diverse containers are equal."""