code: def get_security_group_dict():
    
  
    client = get_ec2_client()
    response = client.describe_security_groups()
    assert is_good_response(response)
  
    result = OrderedDict()
    ec2 = get_ec2_resource()
    for security_group_response in response['SecurityGroups']:
      key = get_name(security_group_response.get('Tags', []))
      if not key or key == EMPTY_NAME:
        continue  # ignore unnamed security groups
      #    key = security_group_response['GroupName']
      if key in result:
        util.log(f"Warning: Duplicate security group {key}")
        if DUPLICATE_CHECKING:
          assert key not in result, ("Duplicate security group " + key)
      result[key] = ec2.SecurityGroup(security_group_response['GroupId'])
  
    return result
docs: Returns dictionary of named security groups {name: securitygroup}.