code: def _get_custom_rule(session, actions=None):
      script_path = os.path.join(
          DATA_DIR, "mxnet_mnist", "my_custom_rule.py"
      )
  
      return Rule.custom(
          name="test-custom-rule",
          source=script_path,
          rule_to_invoke="CustomGradientRule",
          instance_type="ml.m5.xlarge",
          volume_size_in_gb=30,
          image_uri=CUSTOM_RULE_REPO_WITH_PLACEHOLDERS.format(
              CUSTOM_RULE_CONTAINERS_ACCOUNTS_MAP[
                  session.boto_region_name
              ],
              session.boto_region_name,
          ),
          actions=actions,
      )
  
imports: from __future__ import absolute_import
  import os
  import uuid
  import pytest
  from sagemaker.debugger.debugger import DebuggerHookConfig, Rule, rule_configs, TensorBoardOutputConfig
  from sagemaker.mxnet.estimator import MXNet
  from sagemaker.pytorch.estimator import PyTorch
  from sagemaker.tensorflow.estimator import TensorFlow
  from sagemaker.xgboost.estimator import XGBoost
  from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
  from tests.integ.retry import retries
  from tests.integ.timeout import timeout
label_desc: Use image node_id 14 for calling a global function with example usage: _get_custom_rule(session, actions) and returns: Rule