code: def reqToTxn(req):
      
      if isinstance(req, str):
          req = json.loads(req)
      if isinstance(req, dict):
          kwargs = dict(
              identifier=req.get(f.IDENTIFIER.nm, None),
              reqId=req.get(f.REQ_ID.nm, None),
              operation=req.get(OPERATION, None),
              signature=req.get(f.SIG.nm, None),
              signatures=req.get(f.SIGS.nm, None),
              protocolVersion=req.get(f.PROTOCOL_VERSION.nm, None)
          )
          req = TxnUtilConfig.client_request_class(**kwargs)
      if isinstance(req, Request):
          req_data = req.as_dict
          req_data[f.DIGEST.nm] = req.digest
          req_data[f.PAYLOAD_DIGEST.nm] = req.payload_digest
      else:
          raise TypeError(
              "Expected dict or str as input, but got: {}".format(type(req)))
  
      req_data = deepcopy(req_data)
      return do_req_to_txn(req_data=req_data,
                           req_op=req_data[OPERATION])
docs: Transform a client request such that it can be stored in the ledger.
      Also this is what will be returned to the client in the reply
      :param req:
      :return: