code: def from_dict(d, module=None):
      
      # need this here for circular import
      from .. import potential as gala_potential
  
      if module is None:
          potential = gala_potential
      else:
          potential = module
  
      if 'type' in d and d['type'] == 'composite':
          p = getattr(potential, d['class'])()
          for i, component in enumerate(d['components']):
              c = _parse_component(component, module)
              name = component.get('name', str(i))
              p[name] = c
  
      elif 'type' in d and d['type'] == 'custom':
          param_groups = dict()
          for i, component in enumerate(d['components']):
              c = _parse_component(component, module)
  
              try:
                  name = component['name']
              except KeyError:
                  raise KeyError("For custom potentials, component specification "
                                 "must include the component name (e.g., name: "
                                 "'blah')")
  
              params = component.get('parameters', {})
              params = _unpack_params(params) # unpack quantities
              param_groups[name] = params
          p = getattr(potential, d['class'])(**param_groups)
  
      else:
          p = _parse_component(d, module)
  
      return p
docs: Convert a dictionary potential specification into a
      :class:`~gala.potential.PotentialBase` subclass object.
  
      Parameters
      ----------
      d : dict
          Dictionary specification of a potential.
      module : namespace (optional)