def copy_stack_trace(from_var, to_var):
 tr = []
 if (type(from_var) is list):
  for v in from_var:
   tr += getattr(v.tag, 'trace', [])
 else:
  tr = getattr(from_var.tag, 'trace', [])
 if (tr and isinstance(tr[0], tuple)):
  tr = [tr]
 if (type(to_var) is list):
  for v in to_var:
   v.tag.trace = (getattr(v.tag, 'trace', []) + tr)
 else:
  to_var.tag.trace = (getattr(to_var.tag, 'trace', []) + tr)

def copy_stack_trace ( from_var , to_var ) : tr = [ ] if ( type ( from_var ) is list ) : for v in from_var : tr += getattr ( v . tag , 'trace' , [ ] ) else : tr = getattr ( from_var . tag , 'trace' , [ ] ) if ( tr and isinstance ( tr [ 0 ] , tuple ) ) : tr = [ tr ] if ( type ( to_var ) is list ) : for v in to_var : v . tag . trace = ( getattr ( v . tag , 'trace' , [ ] ) + tr ) else : to_var . tag . trace = ( getattr ( to_var . tag , 'trace' , [ ] ) + tr )
copies the stack trace from one or more tensor variables to one or more tensor variables .