<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def _send_signature_request_with_template(self, test_mode=False, client_id=None, template_id=None, template_ids=None, title=None, subject=None, message=None, signing_redirect_url=None, signers=None, ccs=None, custom_fields=None, metadata=None, ux_version=None, allow_decline=False):
        ''' To share the same logic between send_signature_request_with_template
            and send_signature_request_embedded_with_template

        Args:

            test_mode (bool, optional):             Whether this is a test, the signature request will not be legally binding if set to True. Defaults to False.

            client_id (str):                        Client id of the app you're using to create this embedded signature request. Visit the embedded page to learn more about this parameter (https://www.hellosign.com/api/embeddedSigningWalkthrough)

            template_id (str):                      The id of the Template to use when creating the SignatureRequest. Mutually exclusive with template_ids.

            template_ids (list):                    The ids of the Templates to use when creating the SignatureRequest. Mutually exclusive with template_id.

            title (str, optional):                  The title you want to assign to the SignatureRequest

            subject (str, optional):                The subject in the email that will be sent to the signers

            message (str, optional):                The custom message in the email that will be sent to the signers

            signing_redirect_url (str, optional):   The URL you want the signer redirected to after they successfully sign.

            signers (list of dict):                 A list of signers, which each has the following attributes:

                role_name (str):                    Role the signer is assigned to
                name (str):                         The name of the signer
                email_address (str):                Email address of the signer
                pin (str, optional):                The 4- to 12-character access code that will secure this signer's signature page

            ccs (list of dict, optional):           The email address of the CC filling the role of RoleName. Required when a CC role exists for the Template. Each dict has the following attributes:

                role_name (str):                    CC role name
                email_address (str):                CC email address

            custom_fields (list of dict, optional): A list of custom fields. Required when a CustomField exists in the Template. An item of the list should look like this: `{'name: value'}`

            metadata (dict, optional):              Metadata to associate with the signature request

            ux_version (int):                       UX version, either 1 (default) or 2.

            allow_decline (bool, optional):         Allows signers to decline to sign a document if set to 1. Defaults to 0.

        Returns:
            A SignatureRequest object

        '''

        # Signers
        signers_payload = HSFormat.format_dict_list(signers, 'signers', 'role_name')

        # CCs
        ccs_payload = HSFormat.format_dict_list(ccs, 'ccs', 'role_name')

        # Custom fields
        custom_fields_payload = HSFormat.format_custom_fields(custom_fields)

        # Metadata
        metadata_payload = HSFormat.format_single_dict(metadata, 'metadata')

        # Template ids
        template_ids_payload = {}
        if template_ids:
            for i in range(len(template_ids)):
                template_ids_payload["template_ids[%s]" % i] = template_ids[i]

        payload = {
            "test_mode": self._boolean(test_mode),
            "client_id": client_id,
            "template_id": template_id,
            "title": title,
            "subject": subject,
            "message": message,
            "signing_redirect_url": signing_redirect_url,
            "allow_decline": self._boolean(allow_decline)
        }

        if ux_version is not None:
            payload['ux_version'] = ux_version

        # remove attributes with empty value
        payload = HSFormat.strip_none_values(payload)

        url = self.SIGNATURE_REQUEST_CREATE_WITH_TEMPLATE_URL
        if client_id:
            url = self.SIGNATURE_REQUEST_CREATE_EMBEDDED_WITH_TEMPLATE_URL

        data = payload.copy()
        data.update(signers_payload)
        data.update(ccs_payload)
        data.update(custom_fields_payload)
        data.update(metadata_payload)
        data.update(template_ids_payload)

        request = self._get_request()
        response = request.post(url, data=data)

        return response