code: def calc_resource(self, name, value):
      gres = self.global_resources[name]
      if value > gres:
          if name == "_cores":
              name = "threads"
          raise WorkflowError(
              "Job needs {name}={res} but only {name}={gres} "
              "are available. This is likely because two "
              "jobs are connected via a pipe or a service output and have to run "
              "simultaneously. Consider providing more "
              "resources (e.g. via --cores).".format(
                  name=name, res=value, gres=gres
              )
          )
      return value
  
imports: import asyncio
  from collections import defaultdict
  import math
  import os, signal, sys
  import threading
  from functools import partial
  from itertools import chain, accumulate
  from contextlib import ContextDecorator
  from snakemake_interface_executor_plugins.scheduler import JobSchedulerExecutorInterface
  from snakemake_interface_executor_plugins.registry import ExecutorPluginRegistry
  from snakemake_interface_executor_plugins.registry import Plugin
  from snakemake_interface_executor_plugins.settings import ExecMode
  from snakemake.common import async_run
  from snakemake.exceptions import RuleException, WorkflowError, print_exception
  from snakemake.logging import logger
  from fractions import Fraction
label_desc: Use image node_id 21 for calling the JobScheduler obj's underlying member method code with example usage: obj.calc_resource(name, value) and returns: value