code: def _custom_packages(
      user_id: int,
      user_group: int,
      packages: Optional[List[str]] = None,
      shell: Optional[Shell] = None,
  ) -> str:
      """Returns the Dockerfile entries necessary to install custom dependencies for
      the supplied shell and sequence of aptitude packages.
  
      """
      if packages is None:
          packages = []
  
      if shell is None:
          shell = Shell.bash
  
      ret = ""
  
      to_install = sorted(packages + SHELL_DICT[shell].packages)
  
      if len(to_install) != 0:
          commands = apt_command([apt_install(*to_install)])
          ret = """
  USER root
  
  RUN {commands}
  
  USER {user_id}:{user_group}
  """.format_map(
              {
                  "commands": " && ".join(commands),
                  "user_id": user_id,
                  "user_group": user_group,
              }
          )
  
      return ret
  
imports: from __future__ import absolute_import, division, print_function
  import json
  import os
  import subprocess
  import tempfile
  from enum import Enum
  from pathlib import Path
  from typing import Any, Dict, List, NamedTuple, NewType, Optional, Union
  from absl import logging
  from blessings import Terminal
  import caliban.config
  import caliban.util
  import caliban.util.fs
  import caliban.util.metrics
label_desc: Use image node_id 20 for calling a global function with example usage: _custom_packages(user_id, user_group, packages, shell) and returns: ret