code: def backward_transfer_pair(
          backward_channel: NettingChannelState,
          payer_transfer: LockedTransferSignedState,
          pseudo_random_generator: random.Random,
          block_number: BlockNumber,
  ) -> Tuple[Optional[MediationPairState], List[Event]]:
      
      transfer_pair = None
      events: List[Event] = list()
  
      lock = payer_transfer.lock
      lock_timeout = BlockTimeout(lock.expiration - block_number)
  
      # Ensure the refund transfer's lock has a safe expiration, otherwise don't
      # do anything and wait for the received lock to expire.
      if is_channel_usable(backward_channel, lock.amount, lock_timeout):
          message_identifier = message_identifier_from_prng(pseudo_random_generator)
          refund_transfer = channel.send_refundtransfer(
              channel_state=backward_channel,
              initiator=payer_transfer.initiator,
              target=payer_transfer.target,
              amount=get_lock_amount_after_fees(lock, backward_channel),
              message_identifier=message_identifier,
              payment_identifier=payer_transfer.payment_identifier,
              expiration=lock.expiration,
              secrethash=lock.secrethash,
          )
  
          transfer_pair = MediationPairState(
              payer_transfer,
              backward_channel.partner_state.address,
              refund_transfer.transfer,
          )
  
          events.append(refund_transfer)
  
      return (transfer_pair, events)
docs: Sends a transfer backwards, allowing the previous hop to try a new
      route.
  
      When all the routes available for this node failed, send a transfer
      backwards with the same amount and secrethash, allowing the previous hop to
      do a retry.
  
      Args:
          backward_channel: The original channel which sent the mediated transfer
              to this node.
          payer_transfer: The *latest* payer transfer which is backing the
              mediation.
          block_number: The current block number.
  
      Returns:
          The mediator pair and the correspoding refund event.