code: def serialize_input(input, signature_script_hex=''):
      
      if not (isinstance(input, dict) and 'transaction_hash' in input \
              and 'output_index' in input):
          raise Exception('Required parameters: transaction_hash, output_index')
  
      if is_hex(str(input['transaction_hash'])) and len(str(input['transaction_hash'])) != 64:
          raise Exception("Transaction hash '%s' must be 32 bytes" % input['transaction_hash'])
  
      elif not is_hex(str(input['transaction_hash'])) and len(str(input['transaction_hash'])) != 32:
          raise Exception("Transaction hash '%s' must be 32 bytes" % hexlify(input['transaction_hash']))
  
      if not 'sequence' in input:
          input['sequence'] = UINT_MAX
  
      return ''.join([
          flip_endian(input['transaction_hash']),
          hexlify(struct.pack('<I', input['output_index'])),
          hexlify(variable_length_int(len(signature_script_hex)/2)),
          signature_script_hex,
          hexlify(struct.pack('<I', input['sequence']))
      ])
docs: Serializes a transaction input.