class_docstr: A size of a financial instrument for use in trading.
  
  Parameters
  ----------
  instrument : `Instrument`
      The unit of the quantity.
  size : `Decimal`
      The number of units of the instrument.
  path_id : str, optional
      The path order_id that this quantity is allocated for and associated
      with.
  
  Raises
  ------
  InvalidNegativeQuantity
      Raised if the `size` of the quantity being created is negative.
docstr: Validates the given left and right arguments of a numeric or boolean
  operation.
  
  Parameters
  ----------
  left : `Union[Quantity, Number]`
      The left argument of an operation.
  right : `Union[Quantity, Number]`
      The right argument of an operation.
  
  Returns
  -------
  `Tuple[Quantity, Quantity]`
      The validated quantity arguments to use in a numeric or boolean
      operation.
  
  Raises
  ------
  IncompatibleInstrumentOperation
      Raised if the instruments left and right quantities are not equal.
  QuantityOpPathMismatch
      Raised if
          - One argument is locked and the other argument is not.
          - Both arguments are locked quantities with unequal path_ids.
  InvalidNonNumericQuantity
      Raised if either argument is a non-numeric object.
  Exception
      If the operation is not valid.
docstr_tok: ["Validates","the","given","left","and","right","arguments","of","a","numeric","or","boolean","operation",".","Parameters","--","--","--","--","--","left",":","`","Union","[","Quantity",",","Number","]","`","The","left","argument","of","an","operation",".","right",":","`","Union","[","Quantity",",","Number","]","`","The","right","argument","of","an","operation",".","Returns","--","--","--","-","`","Tuple","[","Quantity",",","Quantity","]","`","The","validated","quantity","arguments","to","use","in","a","numeric","or","boolean","operation",".","Raises","--","--","--","IncompatibleInstrumentOperation","Raised","if","the","instruments","left","and","right","quantities","are","not","equal",".","QuantityOpPathMismatch","Raised","if","-","One","argument","is","locked","and","the","other","argument","is","not",".","-","Both","arguments","are","locked","quantities","with","unequal","path_ids",".","InvalidNonNumericQuantity","Raised","if","either","argument","is","a","non-numeric","object",".","Exception","If","the","operation","is","not","valid","."]
code: def validate(
      left: "Union[Quantity, Number]", right: "Union[Quantity, Number]"
  ) -> "Tuple[Quantity, Quantity]":
      """Validates the given left and right arguments of a numeric or boolean
      operation.
  
      Parameters
      ----------
      left : `Union[Quantity, Number]`
          The left argument of an operation.
      right : `Union[Quantity, Number]`
          The right argument of an operation.
  
      Returns
      -------
      `Tuple[Quantity, Quantity]`
          The validated quantity arguments to use in a numeric or boolean
          operation.
  
      Raises
      ------
      IncompatibleInstrumentOperation
          Raised if the instruments left and right quantities are not equal.
      QuantityOpPathMismatch
          Raised if
              - One argument is locked and the other argument is not.
              - Both arguments are locked quantities with unequal path_ids.
      InvalidNonNumericQuantity
          Raised if either argument is a non-numeric object.
      Exception
          If the operation is not valid.
      """
      if isinstance(left, Quantity) and isinstance(right, Quantity):
          if left.instrument != right.instrument:
              raise IncompatibleInstrumentOperation(left, right)
  
          if (left.path_id and right.path_id) and (
              left.path_id != right.path_id
          ):
              raise QuantityOpPathMismatch(left.path_id, right.path_id)
  
          elif left.path_id and not right.path_id:
              right.path_id = left.path_id
  
          elif not left.path_id and right.path_id:
              left.path_id = right.path_id
  
          return left, right
  
      elif isinstance(left, Number) and isinstance(right, Quantity):
          left = Quantity(right.instrument, left, right.path_id)
          return left, right
  
      elif isinstance(left, Quantity) and isinstance(right, Number):
          right = Quantity(left.instrument, right, left.path_id)
          return left, right
  
      elif isinstance(left, Quantity):
          raise InvalidNonNumericQuantity(right)
  
      elif isinstance(right, Quantity):
          raise InvalidNonNumericQuantity(left)
  
      raise Exception(
          f"Invalid quantity operation arguments: {left} and {right}"
      )
  
imports: import operator
  from typing import Union, Tuple, Callable, TypeVar
  from numbers import Number
  from decimal import Decimal, ROUND_DOWN
  from functools import total_ordering
  from tensortrade.core.exceptions import InvalidNegativeQuantity, IncompatibleInstrumentOperation, InvalidNonNumericQuantity, QuantityOpPathMismatch
label_desc: Use image node_id 9 for calling the Quantity obj's underlying member method code with example usage: obj.validate(left, right) and returns: left,  right, left,  right, left,  right