def gamma_trace(t):
    "\n    trace of a single line of gamma matrices\n\n    Examples\n    ========\n\n    >>> from sympy.physics.hep.gamma_matrices import GammaMatrix as G,         gamma_trace, LorentzIndex\n    >>> from sympy.tensor.tensor import tensor_indices, tensor_heads\n    >>> p, q = tensor_heads('p, q', [LorentzIndex])\n    >>> i0,i1,i2,i3,i4,i5 = tensor_indices('i0:6', LorentzIndex)\n    >>> ps = p(i0)*G(-i0)\n    >>> qs = q(i0)*G(-i0)\n    >>> gamma_trace(G(i0)*G(i1))\n    4*metric(i0, i1)\n    >>> gamma_trace(ps*ps) - 4*p(i0)*p(-i0)\n    0\n    >>> gamma_trace(ps*qs + ps*ps) - 4*p(i0)*p(-i0) - 4*p(i0)*q(-i0)\n    0\n\n    "
    if isinstance(t, TensAdd):
        res = TensAdd(*[_trace_single_line(x) for x in t.args])
        return res
    t = _simplify_single_line(t)
    res = _trace_single_line(t)
    return res
trace of a single line of gamma matrices

Examples
========

>>> from sympy.physics.hep.gamma_matrices import GammaMatrix as G,         gamma_trace, LorentzIndex
>>> from sympy.tensor.tensor import tensor_indices, tensor_heads
>>> p, q = tensor_heads('p, q', [LorentzIndex])
>>> i0,i1,i2,i3,i4,i5 = tensor_indices('i0:6', LorentzIndex)
>>> ps = p(i0)*G(-i0)
>>> qs = q(i0)*G(-i0)
>>> gamma_trace(G(i0)*G(i1))
4*metric(i0, i1)
>>> gamma_trace(ps*ps) - 4*p(i0)*p(-i0)
0
>>> gamma_trace(ps*qs + ps*ps) - 4*p(i0)*p(-i0) - 4*p(i0)*q(-i0)
0
def gamma_trace(t):
    "\n    trace of a single line of gamma matrices\n\n    Examples\n    ========\n\n    >>> from sympy.physics.hep.gamma_matrices import GammaMatrix as G,         gamma_trace, LorentzIndex\n    >>> from sympy.tensor.tensor import tensor_indices, tensor_heads\n    >>> p, q = tensor_heads('p, q', [LorentzIndex])\n    >>> i0,i1,i2,i3,i4,i5 = tensor_indices('i0:6', LorentzIndex)\n    >>> ps = p(i0)*G(-i0)\n    >>> qs = q(i0)*G(-i0)\n    >>> gamma_trace(G(i0)*G(i1))\n    4*metric(i0, i1)\n    >>> gamma_trace(ps*ps) - 4*p(i0)*p(-i0)\n    0\n    >>> gamma_trace(ps*qs + ps*ps) - 4*p(i0)*p(-i0) - 4*p(i0)*q(-i0)\n    0\n\n    "
    if isinstance(t, TensAdd):
        res = TensAdd(*[_trace_single_line(x) for x in t.args])
        return res
    t = _simplify_single_line(t)
    res = _trace_single_line(t)
    return res