class_docstr: The tensor product of two or more arguments.
  
  For matrices, this uses ``matrix_tensor_product`` to compute the Kronecker
  or tensor product matrix. For other objects a symbolic ``TensorProduct``
  instance is returned. The tensor product is a non-commutative
  multiplication that is used primarily with operators and states in quantum
  mechanics.
  
  Currently, the tensor product distinguishes between commutative and
  non-commutative arguments.  Commutative arguments are assumed to be scalars
  and are pulled out in front of the ``TensorProduct``. Non-commutative
  arguments remain in the resulting ``TensorProduct``.
  
  Parameters
  ==========
  
  args : tuple
      A sequence of the objects to take the tensor product of.
  
  Examples
  ========
  
  Start with a simple tensor product of SymPy matrices::
  
      >>> from sympy import Matrix
      >>> from sympy.physics.quantum import TensorProduct
  
      >>> m1 = Matrix([[1,2],[3,4]])
      >>> m2 = Matrix([[1,0],[0,1]])
      >>> TensorProduct(m1, m2)
      Matrix([
      [1, 0, 2, 0],
      [0, 1, 0, 2],
      [3, 0, 4, 0],
      [0, 3, 0, 4]])
      >>> TensorProduct(m2, m1)
      Matrix([
      [1, 2, 0, 0],
      [3, 4, 0, 0],
      [0, 0, 1, 2],
      [0, 0, 3, 4]])
  
  We can also construct tensor products of non-commutative symbols:
  
      >>> from sympy import Symbol
      >>> A = Symbol('A',commutative=False)
      >>> B = Symbol('B',commutative=False)
      >>> tp = TensorProduct(A, B)
      >>> tp
      AxB
  
  We can take the dagger of a tensor product (note the order does NOT reverse
  like the dagger of a normal product):
  
      >>> from sympy.physics.quantum import Dagger
      >>> Dagger(tp)
      Dagger(A)xDagger(B)
  
  Expand can be used to distribute a tensor product across addition:
  
      >>> C = Symbol('C',commutative=False)
      >>> tp = TensorProduct(A+B,C)
      >>> tp
      (A + B)xC
      >>> tp.expand(tensorproduct=True)
      AxC + BxC
class_docstr_tok: ["The","tensor","product","of","two","or","more","arguments",".","For","matrices",",","this","uses","``","matrix_tensor_product","``","to","compute","the","Kronecker","or","tensor","product","matrix",".","For","other","objects","a","symbolic","``","TensorProduct","``","instance","is","returned",".","The","tensor","product","is","a","non-commutative","multiplication","that","is","used","primarily","with","operators","and","states","in","quantum","mechanics",".","Currently",",","the","tensor","product","distinguishes","between","commutative","and","non-commutative","arguments",".","Commutative","arguments","are","assumed","to","be","scalars","and","are","pulled","out","in","front","of","the","``","TensorProduct","``",".","Non-commutative","arguments","remain","in","the","resulting","``","TensorProduct","``",".","Parameters","==========","args",":","tuple","A","sequence","of","the","objects","to","take","the","tensor","product","of",".","Examples","========","Start","with","a","simple","tensor","product","of","SymPy","matrices",":",":",">",">",">","from","sympy","import","Matrix",">",">",">","from","sympy.physics.quantum","import","TensorProduct",">",">",">","m1","=","Matrix","(","[","[","1,2","]",",","[","3,4","]","]",")",">",">",">","m2","=","Matrix","(","[","[","1,0","]",",","[","0,1","]","]",")",">",">",">","TensorProduct","(","m1",",","m2",")","Matrix","(","[","[","1",",","0",",","2",",","0","]",",","[","0",",","1",",","0",",","2","]",",","[","3",",","0",",","4",",","0","]",",","[","0",",","3",",","0",",","4","]","]",")",">",">",">","TensorProduct","(","m2",",","m1",")","Matrix","(","[","[","1",",","2",",","0",",","0","]",",","[","3",",","4",",","0",",","0","]",",","[","0",",","0",",","1",",","2","]",",","[","0",",","0",",","3",",","4","]","]",")","We","can","also","construct","tensor","products","of","non-commutative","symbols",":",">",">",">","from","sympy","import","Symbol",">",">",">","A","=","Symbol","(","'","A","'",",","commutative=False",")",">",">",">","B","=","Symbol","(","'","B","'",",","commutative=False",")",">",">",">","tp","=","TensorProduct","(","A",",","B",")",">",">",">","tp","AxB","We","can","take","the","dagger","of","a","tensor","product","(","note","the","order","does","NOT","reverse","like","the","dagger","of","a","normal","product",")",":",">",">",">","from","sympy.physics.quantum","import","Dagger",">",">",">","Dagger","(","tp",")","Dagger","(","A",")","xDagger","(","B",")","Expand","can","be","used","to","distribute","a","tensor","product","across","addition",":",">",">",">","C","=","Symbol","(","'","C","'",",","commutative=False",")",">",">",">","tp","=","TensorProduct","(","A+B",",","C",")",">",">",">","tp","(","A","+","B",")","xC",">",">",">","tp.expand","(","tensorproduct=True",")","AxC","+","BxC"]
docstr: Distribute TensorProducts across addition.
docstr_tok: ["Distribute","TensorProducts","across","addition","."]
code: def _eval_expand_tensorproduct(self, **hints):
      """Distribute TensorProducts across addition."""
      args = self.args
      add_args = []
      for i in range(len(args)):
          if isinstance(args[i], Add):
              for aa in args[i].args:
                  tp = TensorProduct(*args[:i] + (aa,) + args[i + 1 :])
                  c_part, nc_part = tp.args_cnc()
                  # Check for TensorProduct object: is the one object in nc_part, if any:
                  # (Note: any other object type to be expanded must be added here)
                  if len(nc_part) == 1 and isinstance(
                      nc_part[0], TensorProduct
                  ):
                      nc_part = (
                          nc_part[0]._eval_expand_tensorproduct(),
                      )
                  add_args.append(Mul(*c_part) * Mul(*nc_part))
              break
  
      if add_args:
          return Add(*add_args)
      else:
          return self
  
imports: from sympy.core.add import Add
  from sympy.core.expr import Expr
  from sympy.core.mul import Mul
  from sympy.core.power import Pow
  from sympy.core.sympify import sympify
  from sympy.matrices.dense import DenseMatrix
  from sympy.matrices.immutable import ImmutableDenseMatrix
  from sympy.printing.pretty.stringpict import prettyForm
  from sympy.physics.quantum.qexpr import QuantumError
  from sympy.physics.quantum.dagger import Dagger
  from sympy.physics.quantum.commutator import Commutator
  from sympy.physics.quantum.anticommutator import AntiCommutator
  from sympy.physics.quantum.state import Ket, Bra
  from sympy.physics.quantum.matrixutils import numpy_ndarray, scipy_sparse_matrix, matrix_tensor_product
  from sympy.physics.quantum.trace import Tr
label_desc: Use image node_id 9 for calling the TensorProduct obj's underlying member method code with example usage: obj._eval_expand_tensorproduct() and returns: Add, self