@classmethod
def custom(cls, name, image_uri, instance_type, volume_size_in_gb, source=
    None, rule_to_invoke=None, container_local_output_path=None,
    s3_output_path=None, other_trials_s3_input_paths=None, rule_parameters=
    None, collections_to_save=None):
    """Initialize a ``Rule`` instance for a custom rule. The Rule
        analyzes tensors emitted during the training of a model and
        monitors conditions that are critical for the success of a
        training job.

        Args:
            name (str): The name of the debugger rule.
            image_uri (str): The URI of the image to be used by the debugger rule.
            instance_type (str): Type of EC2 instance to use, for example,
                'ml.c4.xlarge'.
            volume_size_in_gb (int): Size in GB of the EBS volume
                to use for storing data.
            source (str): A source file containing a rule to invoke. If provided,
                you must also provide rule_to_invoke. This can either be an S3 uri or
                a local path.
            rule_to_invoke (str): The name of the rule to invoke within the source.
                If provided, you must also provide source.
            container_local_output_path (str): The path in the container.
            s3_output_path (str): The location in S3 to store the output.
            other_trials_s3_input_paths ([str]): S3 input paths for other trials.
            rule_parameters (dict): A dictionary of parameters for the rule.
            collections_to_save ([sagemaker.debugger.CollectionConfig]): A list
                of CollectionConfig objects to be saved.

        Returns:
            sagemaker.debugger.Rule: The instance of the custom Rule.
        """
    if bool(source) ^ bool(rule_to_invoke):
        raise ValueError(
            'If you provide a source, you must also provide a rule to invoke (and vice versa).'
            )
    merged_rule_params = {}
    if source is not None and rule_to_invoke is not None:
        merged_rule_params['source_s3_uri'] = source
        merged_rule_params['rule_to_invoke'] = rule_to_invoke
    other_trials_params = {}
    if other_trials_s3_input_paths is not None:
        for index, s3_input_path in enumerate(other_trials_s3_input_paths):
            other_trials_params['other_trial_{}'.format(str(index))
                ] = s3_input_path
    merged_rule_params.update(other_trials_params)
    merged_rule_params.update(rule_parameters or {})
    return cls(name=name, image_uri=image_uri, instance_type=instance_type,
        container_local_output_path=container_local_output_path,
        s3_output_path=s3_output_path, volume_size_in_gb=volume_size_in_gb,
        rule_parameters=merged_rule_params, collections_to_save=
        collections_to_save or [])
